def clear_objects(self, *args, **kwargs):
        """
        Same as the function in engine, clear objects, Return exclude object ids

        filter: A list of object ids or a function returning a list of object id
        """
        exclude_objects = self.engine.clear_objects(*args, **kwargs)
        for obj in exclude_objects:
            self.spawned_objects.pop(obj)
        return exclude_objects

        Same as the function in engine, clear objects, Return exclude object ids

        filter: A list of object ids or a function returning a list of object id
        
metadrive/manager/base_manager.py