code: def retain_identities(retention_time, es_enrichment_url, sortinghat_db, data_source, active_data_sources):
      
      before_date = get_diff_current_date(minutes=retention_time)
      before_date_str = before_date.isoformat()
  
      es = Elasticsearch([es_enrichment_url], timeout=120, max_retries=20, retry_on_timeout=True, verify_certs=False)
  
      # delete the unique identities which have not been seen after `before_date`
      delete_inactive_unique_identities(es, sortinghat_db, before_date_str)
      # delete the unique identities for a given data source which are not in the IDENTITIES_INDEX
      delete_orphan_unique_identities(es, sortinghat_db, data_source, active_data_sources)
docs: Select the unique identities not seen before `retention_time` and
      delete them from SortingHat. Furthermore, it deletes also the orphan unique identities,
      those ones stored in SortingHat but not in IDENTITIES_INDEX.
  
      :param retention_time: maximum number of minutes wrt the current date to retain the identities
      :param es_enrichment_url: URL of the ElasticSearch where the enriched data is stored
      :param sortinghat_db: instance of the SortingHat database
      :param data_source: target data source (e.g., git, github, slack)
      :param active_data_sources: list of active data sources