def group_iterate(self,
                    query_info,
                    passage_list,
                    max_cand,
                    is_training,
                    train_eval=False):
    """Iterates over the passage candidates in groups of specified number."""
    # first shuffle the list
    if is_training:
      random.shuffle(passage_list)  # These are PassageInfos
    index_correct = RetrievalProcessor.get_index_correct(passage_list)

    rotate_group = passage_list
    # for training this becomes all passages except for one singled as correct

    if is_training:
      rotate_group = []
      max_cand = max_cand - 1
      for (i, p) in enumerate(passage_list):
        if i == index_correct:
          continue
        rotate_group.append(p)
    start = 0

    while start < len(rotate_group):
      end = start + max_cand
      if end > len(rotate_group):
        move = end - len(rotate_group)
        start = start - move
        end = end - move

      passages = rotate_group[start:end]

      if is_training:
        passages.insert(0, passage_list[index_correct])

      yield self.emit(query_info, passages)
      if is_training and FLAGS.single_per_query and not train_eval:
        break  # we want each query to appear only once in training except when
        # we generate a special set for training eval
      start = end
Iterates over the passage candidates in groups of specified number.
language/multivec/preprocessing/create_training_data.py