def load_captions(captions_file, vocab):
  """Loads image ids and processes the captions.

  Args:
    captions_file: JSON file containing caption annotations.
    vocab: A text_utils.Vocab instance.

  Returns:
    captions: Dictionary of image_id --> captions.
  """
  tf.logging.info("Loading captions from %s", captions_file)
  with tf.io.gfile.GFile(captions_file, "r") as f:
    caption_data = json.load(f)
  image_to_captions = collections.defaultdict(list)
  for annotation in caption_data["annotations"]:
    image_id = annotation["image_id"]
    caption_tokens = vocab.tokenize(annotation["caption"])
    image_to_captions[image_id].append(" ".join(caption_tokens))
  return image_to_captions
Loads image ids and processes the captions.

  Args:
    captions_file: JSON file containing caption annotations.
    vocab: A text_utils.Vocab instance.

  Returns:
    captions: Dictionary of image_id --> captions.
  
language/capwap/preprocessing/coco_ood_captions.py