<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def load(self, entity_class, entity):
 """ Load the given repository entity into the session and return a clone. If it was already loaded before, look up the loaded entity and return it. All entities referenced by the loaded entity will also be loaded (and cloned) recursively. :raises ValueError: When an attempt is made to load an entity that has no ID """

        if self.__needs_flushing:
            self.flush()
        if entity.id is None:
            raise ValueError('Can not load entity without an ID.')
        cache = self.__get_cache(entity_class)
        sess_ent = cache.get_by_id(entity.id)
        if sess_ent is None:
            if self.__clone_on_load:
                sess_ent = self.__clone(entity, cache)
            else: # Only needed by the nosql backend pragma: no cover
                cache.add(entity)
                sess_ent = entity
            self.__unit_of_work.register_clean(entity_class, sess_ent)
        return sess_ent