code: def _clear_dead_entities(self):
          
          for entity in self._dead_entities:
  
              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._dead_entities.clear()
          self.clear_cache()
docs: Finalize deletion of any Entities that are marked dead.
          
          In the interest of performance, this method duplicates code from the
          `delete_entity` method. If that method is changed, those changes should
          be duplicated here as well.