code: def _resolve_reference_sample(self, reference_samples=None,
                                    service_uids=None):
          
          if not reference_samples:
              return None, list()
  
          if not service_uids:
              # Since no service filtering has been defined, there is no need to
              # look for the best choice. Return the first one
              sample = reference_samples[0]
              spec_uids = sample.getSupportedServices(only_uids=True)
              return sample, spec_uids
  
          best_score = [0, 0]
          best_sample = None
          best_supported = None
          for sample in reference_samples:
              specs_uids = sample.getSupportedServices(only_uids=True)
              supported = [uid for uid in specs_uids if uid in service_uids]
              matches = len(supported)
              overlays = len(service_uids) - matches
              overlays = 0 if overlays < 0 else overlays
  
              if overlays == 0 and matches == len(service_uids):
                  # Perfect match.. no need to go further
                  return sample, supported
  
              if not best_sample \
                      or matches > best_score[0] \
                      or (matches == best_score[0] and overlays < best_score[1]):
                  best_sample = sample
                  best_score = [matches, overlays]
                  best_supported = supported
  
          return best_sample, best_supported
docs: Returns the reference sample from reference_samples passed in that fits
          better with the service uid requirements. This is, the reference sample
          that covers most (or all) of the service uids passed in and has less
          number of remaining service_uids.
  
          If no reference_samples are set, returns None
  
          If no service_uids are set, returns the first reference_sample
  
          :param reference_samples: list of reference samples
          :param service_uids: list of service uids
          :return: the reference sample that fits better with the service uids