def indicator_score(captions, answers):
  """Compute indicator score (1 if answer is contained in the caption, else 0).

  Args:
    captions: Dictionary of image_id --> question_id --> list(caption).
    answers: Dictionary of image_id --> question_id --> list(answers).

  Returns:
    results: Dictionary of indicator score.
  """
  indicator = total = 0.0
  for image_id, questions in captions.items():
    for question_id, ground_truths in answers[image_id].items():
      # If the specific question_id is not here, then we use the caption for the
      # whole image (i.e., we're not doing conditional decoding). Let's just
      # assert that there is indeed only one caption in this case.
      if question_id not in questions:
        assert len(questions) == 1
        image_captions = next(iter(questions.values()))
      else:
        image_captions = questions[question_id]
      indicator += metric_max_over_ground_truths(compute_indicator,
                                                 image_captions, ground_truths)
      total += 1
  results = dict(indicator=indicator / total)
  tf.logging.info("Computed indicator score on %d values.", total)
  return results
Compute indicator score (1 if answer is contained in the caption, else 0).

  Args:
    captions: Dictionary of image_id --> question_id --> list(caption).
    answers: Dictionary of image_id --> question_id --> list(answers).

  Returns:
    results: Dictionary of indicator score.
  
language/capwap/utils/metric_utils.py