<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def restore_retention_data(self, data):
 """Restore retention data Data coming from retention will override data coming from configuration It is kinda confusing when you modify an attribute (external command) and it get saved by retention :param data: data from retention :type data: dict :return: None """

        if 'hosts' not in data:
            logger.warning("Retention data are not correct, no 'hosts' property!")
            return

        for host_name in data['hosts']:
            # We take the dict of our value to load
            host = self.hosts.find_by_name(host_name)
            if host is not None:
                self.restore_retention_data_item(data['hosts'][host_name], host)
        statsmgr.gauge('retention.hosts', len(data['hosts']))
        logger.info('%d hosts restored from retention', len(data['hosts']))

        # Same for services
        for (host_name, service_description) in data['services']:
            # We take our dict to load
            service = self.services.find_srv_by_name_and_hostname(host_name, service_description)
            if service is not None:
                self.restore_retention_data_item(data['services'][(host_name, service_description)],
                                                 service)
        statsmgr.gauge('retention.services', len(data['services']))
        logger.info('%d services restored from retention', len(data['services']))