class_docstr: Coco Caption evaluation wrapper.
  
  Save the generated captions and transform into coco format.
  Calling COCO API for caption metrics.
  
  Args:
      ann_file (str): the path for the COCO format caption ground truth
          json file, load for evaluations.
      collect_device (str): Device name used for collecting results from
          different ranks during distributed training. Must be 'cpu' or
          'gpu'. Defaults to 'cpu'.
      prefix (str, optional): The prefix that will be added in the metric
          names to disambiguate homonymous metrics of different evaluators.
          If prefix is not provided in the argument, self.default_prefix
          will be used instead. Should be modified according to the
          `retrieval_type` for unambiguous results. Defaults to TR.
class_docstr_tok: ["Coco","Caption","evaluation","wrapper",".","Save","the","generated","captions","and","transform","into","coco","format",".","Calling","COCO","API","for","caption","metrics",".","Args",":","ann_file","(","str",")",":","the","path","for","the","COCO","format","caption","ground","truth","json","file",",","load","for","evaluations",".","collect_device","(","str",")",":","Device","name","used","for","collecting","results","from","different","ranks","during","distributed","training",".","Must","be","'cpu","'","or","'gpu","'",".","Defaults","to","'cpu","'",".","prefix","(","str",",","optional",")",":","The","prefix","that","will","be","added","in","the","metric","names","to","disambiguate","homonymous","metrics","of","different","evaluators",".","If","prefix","is","not","provided","in","the","argument",",","self.default_prefix","will","be","used","instead",".","Should","be","modified","according","to","the","`","retrieval_type","`","for","unambiguous","results",".","Defaults","to","TR","."]
docstr: Process one batch of data samples.
  
  The processed results should be stored in ``self.results``, which will
  be used to computed the metrics when all batches have been processed.
  
  Args:
      data_batch: A batch of data from the dataloader.
      data_samples (Sequence[dict]): A batch of outputs from the model.
docstr_tok: ["Process","one","batch","of","data","samples",".","The","processed","results","should","be","stored","in","``","self.results","``",",","which","will","be","used","to","computed","the","metrics","when","all","batches","have","been","processed",".","Args",":","data_batch",":","A","batch","of","data","from","the","dataloader",".","data_samples","(","Sequence","[","dict","]",")",":","A","batch","of","outputs","from","the","model","."]
code: def process(self, data_batch, data_samples):
      """Process one batch of data samples.
  
      The processed results should be stored in ``self.results``, which will
      be used to computed the metrics when all batches have been processed.
  
      Args:
          data_batch: A batch of data from the dataloader.
          data_samples (Sequence[dict]): A batch of outputs from the model.
      """
  
      for data_sample in data_samples:
          result = dict()
  
          result["caption"] = data_sample["pred_caption"]
          result["image_id"] = int(data_sample["img_id"])
  
          # Save the result to `self.results`.
          self.results.append(result)
  
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 the COCOCaptionMetric obj's underlying member method code with example usage: obj.process(data_batch, data_samples) without return types