code: def _get_representative_batch(merged):
      
      out = {}
      for mgroup in merged:
          mgroup = sorted(list(mgroup))
          for x in mgroup:
              out[x] = mgroup[0]
      return out
docs: Prepare dictionary matching batch items to a representative within a group.