code: def coco_caption_eval(results_file, ann_file):
      """Evaluation between gt json and prediction json files."""
      # create coco object and coco_result object
      coco = COCO(ann_file)
      coco_result = coco.loadRes(results_file)
  
      # create coco_eval object by taking coco and coco_result
      coco_eval = COCOEvalCap(coco, coco_result)
  
      # make sure the image ids are the same
      coco_eval.params["image_id"] = coco_result.getImgIds()
  
      # This will take some times at the first run
      coco_eval.evaluate()
  
      # print output evaluation scores
      for metric, score in coco_eval.eval.items():
          print(f"{metric}: {score:.3f}")
  
      return coco_eval.eval
  
file_path: mmdetection/mmdet/evaluation/metrics/coco_caption_metric.py
imports: import json
  import os
  import tempfile
  from typing import List, Optional
  from mmengine.evaluator import BaseMetric
  from mmengine.utils import track_iter_progress
  from pycocotools.coco import COCO
  from mmdet.registry import METRICS
label_desc: Use image node_id 2 for calling a global function with example usage: coco_caption_eval(results_file, ann_file) and returns: coco_eval