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

  Args:
    questions_file: JSON file containing VIZWIZ questions.
    vocab: A text_utils.Vocab instance.

  Returns:
    questions: Dictionary of image_id --> question/answers.
  """
  tf.logging.info("Loading %s", questions_file)
  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:
    # Skip yes/no and unanswerable.
    if not entry["answerable"]:
      continue
    if entry["answer_type"] == "yes/no":
      continue
    if entry["answer_type"] == "unanswerable":
      continue

    question = entry["question"]
    original_answers = [a["answer"] for a in entry["answers"]]

    # 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

    # Select the most common answer and put it first; it will then get picked
    # for training by default.
    answers = [a[0] for a in collections.Counter(answers).most_common()]

    image_id = os.path.splitext(entry["image"])[0]
    image_id = int(image_id.split("_")[-1])
    question = " ".join(vocab.tokenize(question))
    answers = [" ".join(vocab.tokenize(answer)) for answer in answers]
    questions[image_id]["question_ids"].append(image_id)
    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 VIZWIZ questions.

  Args:
    questions_file: JSON file containing VIZWIZ questions.
    vocab: A text_utils.Vocab instance.

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