def get_grouped_candidates_v2(processor,
                              queries,
                              passages,
                              neighbors_path,
                              q_ids,
                              max_cand,
                              is_training,
                              train_eval=False):
  """For each query, selecting positive and negative candidates."""
  for q_info, p_infos_positive, p_infos_negative in generate_samples_v2(
      queries,
      passages,
      neighbors_path,
      is_training,
      processor,
      q_ids,
      train_eval=train_eval):
    if q_info.id not in q_ids:
      continue
    for example in processor.get_examples_v2(is_training, max_cand, q_info,
                                             p_infos_positive,
                                             p_infos_negative):
      yield example
For each query, selecting positive and negative candidates.
language/multivec/preprocessing/create_training_data.py