<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _populate_sub_entity(self, entity, type_name):
 """ Simple API-backed cache for populating MyGeotab entities :param entity: The entity to populate a sub-entity for :param type_name: The type of the sub-entity to populate """

        key = type_name.lower()
        if isinstance(entity[key], str):
            # If the expected sub-entity is a string, it's a unknown ID
            entity[key] = dict(id=entity[key])
            return
        cache = self._cache[key]
        subentity = cache.get(entity[key]['id'])
        if not subentity:
            subentities = self.api.get(type_name, id=entity[key]['id'], results_limit=1)
            if len(subentities) > 0:
                subentity = subentities[0]
                entity[key] = subentity
        else:
            entity[key] = subentity