<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def delete_entity(self, entity: int, immediate=False) -> None: """Delete an Entity from the World. Delete an Entity and all of it's assigned Component instances from the world. By default, Entity deletion is delayed until the next call to *World.process*. You can request immediate deletion, however, by passing the "immediate=True" parameter. This should generally not be done during Entity iteration (calls to World.get_component/s). Raises a KeyError if the given entity does not exist in the database. :param entity: The Entity ID you wish to delete. :param immediate: If True, delete the Entity immediately. """

        if immediate:
            for component_type in self._entities[entity]:
                self._components[component_type].discard(entity)

                if not self._components[component_type]:
                    del self._components[component_type]

            del self._entities[entity]
            self.clear_cache()

        else:
            self._dead_entities.add(entity)