def load_questions(questions_file, annotations_file, vocab):
  """Load and process VQA questions.

  Args:
    questions_file: JSON file containing VQA questions.
    annotations_file: JSON file containing VQA answers.
    vocab: A text_utils.Vocab instance.

  Returns:
    questions: Dictionary of image_id --> question/answers.
  """
  with tf.io.gfile.GFile(annotations_file, "r") as f:
    annotations = json.load(f)

  # Build mapping of question id to answer list. There are multiple answers from
  # different annotations for each question. We keep all of them, but put the
  # best (most common) answer first so it gets picked for training by default.
  qid_to_answer = {}
  for annotation in annotations["annotations"]:
    qid = annotation["question_id"]
    best = annotation["multiple_choice_answer"]
    answers = set([a["answer"] for a in annotation["answers"]]) - set(best)
    answers = [best] + list(answers)
    qid_to_answer[qid] = answers

  with tf.io.gfile.GFile(questions_file, "r") as f:
    data = json.load(f)

  total = skipped = 0
  questions = collections.defaultdict(lambda: collections.defaultdict(list))
  for entry in data["questions"]:
    image_id = entry["image_id"]
    question = entry["question"]
    qid = entry["question_id"]
    original_answers = qid_to_answer[qid]

    # Filter non-applicable questions (check all allowed answers).
    total += 1
    answers = []
    majority = 0
    for answer in original_answers:
      if io_utils.filter_question(question, answer):
        majority -= 1
      else:
        majority += 1
        answers.append(answer)
    if not answers or majority <= 0:
      skipped += 1
      continue

    question = " ".join(vocab.tokenize(question))
    answers = [" ".join(vocab.tokenize(answer)) for answer in answers]
    questions[image_id]["question_ids"].append(int(qid))
    questions[image_id]["questions"].append(question)
    questions[image_id]["answers"].append(answers)
  tf.logging.info("Filtered: %d/%d", skipped, total)
  tf.logging.info("Kept: %d", total - skipped)
  return questions
Load and process VQA questions.

  Args:
    questions_file: JSON file containing VQA questions.
    annotations_file: JSON file containing VQA answers.
    vocab: A text_utils.Vocab instance.

  Returns:
    questions: Dictionary of image_id --> question/answers.
  
language/capwap/preprocessing/vqa_qa.py