code: def select_best_haplotype_match(all_matches):
      """Returns the best HaplotypeMatch among all_matches.
  
      The best matching HaplotypeMatch is the one with the lowest match_metrics
      score.
  
      Args:
        all_matches: iterable[HaplotypeMatch]. An iterable of HaplotypeMatch objects
          we want to select the best match from.
  
      Returns:
        The best matching HaplotypeMatch object.
      """
      sorted_matches = sorted(
          all_matches, key=lambda x: x.match_metrics
      )
      best = sorted_matches[0]
      equivalents = [
          f
          for f in all_matches
          if f.match_metrics == best.match_metrics
      ]
  
      # TODO: Why is this triggering so much?
      if len(equivalents) > 1:
          for i, f in enumerate(equivalents):
              extra_info = "best" if i == 0 else i
              logging.warning(
                  "Equivalent match to best: %s [%s]", f, extra_info
              )
  
      return equivalents[0]
  
imports: import collections
  import copy
  import enum
  import heapq
  import itertools
  from absl import logging
  from deepvariant.labeler import variant_labeler
  from deepvariant.protos import deepvariant_pb2
  from third_party.nucleus.io import fasta
  from third_party.nucleus.util import ranges
  from third_party.nucleus.util import variant_utils
  from third_party.nucleus.util import variantcall_utils
label_desc: Use image node_id 13 for calling a global function with example usage: select_best_haplotype_match(all_matches) and returns: equivalents