code: def _group_by_batches(samples, check_fn):
      
      batch_groups = collections.defaultdict(list)
      extras = []
      for data in [x[0] for x in samples]:
          if check_fn(data):
              batch_groups[multi.get_batch_for_key(data)].append(data)
          else:
              extras.append([data])
      return batch_groups, extras
docs: Group calls by batches, processing families together during ensemble calling.