input: Write a function to implement a hash table in Python that supports insert, delete, and retrieve operations. If the given key does not exist in the hash table during delete or retrieve operations, raise a KeyError.
  
  class HashTable:
      def __init__(self):
          self.table = [[] for _ in range(256)]
   
      def insert(self, key, value):
          h = hash(key) % 256
          for i, kv in enumerate(self.table[h]):
              if kv[0] == key:
                  self.table[h][i] = (key, value)
                  return
          self.table[h].append((key, value))
   
      def retrieve(self, key):
          h = hash(key) % 256
          for kv in self.table[h]:
              if kv[0] == key:
                  return kv[1]
          raise KeyError(f"Key '{key}' not found in the hash table.")
   
      def delete(self, key):
          h = hash(key) % 256
          for i, kv in enumerate(self.table[h]):
              if kv[0] == key:
                  del self.table[h][i]
                  return
          raise KeyError(f"Key '{key}' not found in the hash table.")
  
  assert isinstance(HashTable().table, list)
  assert HashTable().table == [[] for _ in range(256)]
  ht = HashTable()
  ht.insert("key1", "value1")
  assert ht.retrieve("key1") == "value1"
  ht.insert("key1", "new_value1")
  assert ht.retrieve("key1") == "new_value1"
  ht.delete("key1")
  try:
      ht.retrieve("key1")
      assert False
  except KeyError:
      assert True
  
  try:
      ht.delete("nonexistent_key")
      assert False
  except KeyError:
      assert True
output: def __init__(self):
      self.table = [[] for _ in range(256)]
  
  def insert(self, key, value):
      h = hash(key) % 256
      for i, kv in enumerate(self.table[h]):
          if kv[0] == key:
              self.table[h][i] = (key, value)
              return
      self.table[h].append((key, value))
  
  def retrieve(self, key):
      h = hash(key) % 256
      for kv in self.table[h]:
          if kv[0] == key:
              return kv[1]
      raise KeyError(f"Key '{key}' not found in the hash table.")
  
  def delete(self, key):
      h = hash(key) % 256
      for i, kv in enumerate(self.table[h]):
          if kv[0] == key:
              del self.table[h][i]
              return
      raise KeyError(f"Key '{key}' not found in the hash table.")