def load_references(image_ids, coco_annotations):
  """Load COCO references from file.

  References are tokenized in the PTB-style.

  Args:
    image_ids: Image ids to load references for.
    coco_annotations: Path to COCO data directory.

  Returns:
    references: Dictionary of image_id --> list(captions)
  """
  references = collections.defaultdict(list)
  val_file = "%s/captions_%s2014.json" % (coco_annotations, "val")
  train_file = "%s/captions_%s2014.json" % (coco_annotations, "train")

  for filename in [val_file, train_file]:
    with tf.io.gfile.GFile(filename, "r") as f:
      data = json.load(f)
    for annotation in data["annotations"]:
      image_id = annotation["image_id"]
      if image_id not in image_ids:
        continue
      caption = clean_tokens(nltk_utils.word_tokenize(annotation["caption"]))
      references[image_id].append(" ".join(caption))
  return references
Load COCO references from file.

  References are tokenized in the PTB-style.

  Args:
    image_ids: Image ids to load references for.
    coco_annotations: Path to COCO data directory.

  Returns:
    references: Dictionary of image_id --> list(captions)
  
language/capwap/utils/metric_utils.py