def augmented_neighbors_list(q_id,
                             neighbors,
                             is_training,
                             processor,
                             train_eval=False):
  """Retrieve and convert the neighbors to a list.

  Args:
    q_id: a question id
    neighbors: a table mapping q_id to a list of top candidates
    is_training: True for training set examples
    processor: Helper object
    train_eval: If this is on, we have a sub-set of the training set for which
      we don't add the gold answer if it is not in the neighbors list

  Returns:
     lists of passage ids, list of corresponding labels, list of scores,
     and the index of the first random negative


  """
  n_pb = neighbors[q_id]
  n_list = []
  n_labels = []
  n_scores = []  # the higher, the better

  n_positive = 0
  answers = processor.get_answers(q_id)

  for n in range(len(n_pb)):
    if n >= FLAGS.max_neighbors:
      break  # ignore any later neighbors
    next_n = n_pb[n]

    if processor.answer_match(q_id, next_n[0], answers):
      n_list.append(next_n[0])
      n_labels.append(1)
      n_scores.append(-next_n[1])
      n_positive += 1

    else:
      # see if we keep it
      n_list.append(next_n[0])
      n_labels.append(0)
      n_scores.append(-next_n[1])
  if not n_positive:
    if (is_training or FLAGS.add_gold_to_eval):
      gold_p_id = processor.get_gold_passage_id(q_id)
      if gold_p_id is None and is_training:
        print("Did not find answer matches.")
        return [], [], [], 0
      if gold_p_id is not None:
        n_list.append(gold_p_id)
        n_labels.append(1)
        prior_gold = 0
        n_scores.append(prior_gold)
        n_positive += 1
    else:
      if is_training:
        print("Did not find answer matches.")
        return [], [], [], 0

  # add the same number of random examples as we have neighbors
  # we should add about
  # (FLAGS.num_candidates -1) * FLAGS. train_records_per_query/2 random
  index_rand_start = len(n_list)
  num_random = index_rand_start
  if is_training and not train_eval:  # getting fewer random for speed
    num_random = (int)(
        (FLAGS.num_candidates - 1) * FLAGS.train_records_per_query / 2)

  if FLAGS.add_random:
    random_passages = processor.get_random(num_random)
    random_labels = []
    random_scores = [0] * num_random
    for r in range(len(random_passages)):
      n_scores.append(random_scores[r])
      if processor.answer_match(q_id, random_passages[r], answers):
        random_labels.append(1)
      else:
        random_labels.append(0)
    n_list.extend(random_passages)
    n_labels.extend(random_labels)

  return n_list, n_labels, n_scores, index_rand_start
Retrieve and convert the neighbors to a list.

  Args:
    q_id: a question id
    neighbors: a table mapping q_id to a list of top candidates
    is_training: True for training set examples
    processor: Helper object
    train_eval: If this is on, we have a sub-set of the training set for which
      we don't add the gold answer if it is not in the neighbors list

  Returns:
     lists of passage ids, list of corresponding labels, list of scores,
     and the index of the first random negative


  
language/multivec/preprocessing/create_training_data.py