class_docstr: COCO evaluation metric.
  
  Evaluate AR, AP, and mAP for detection tasks including proposal/box
  detection and instance segmentation. Please refer to
  https://cocodataset.org/#detection-eval for more details.
  
  Args:
      ann_file (str, optional): Path to the coco format annotation file.
          If not specified, ground truth annotations from the dataset will
          be converted to coco format. Defaults to None.
      metric (str | List[str]): Metrics to be evaluated. Valid metrics
          include 'bbox', 'segm', 'proposal', and 'proposal_fast'.
          Defaults to 'bbox'.
      classwise (bool): Whether to evaluate the metric class-wise.
          Defaults to False.
      proposal_nums (Sequence[int]): Numbers of proposals to be evaluated.
          Defaults to (100, 300, 1000).
      iou_thrs (float | List[float], optional): IoU threshold to compute AP
          and AR. If not specified, IoUs from 0.5 to 0.95 will be used.
          Defaults to None.
      metric_items (List[str], optional): Metric result names to be
          recorded in the evaluation result. Defaults to None.
      format_only (bool): Format the output results without perform
          evaluation. It is useful when you want to format the result
          to a specific format and submit it to the test server.
          Defaults to False.
      outfile_prefix (str, optional): The prefix of json files. It includes
          the file path and the prefix of filename, e.g., "a/b/prefix".
          If not specified, a temp file will be created. Defaults to None.
      file_client_args (dict, optional): Arguments to instantiate the
          corresponding backend in mmdet <= 3.0.0rc6. Defaults to None.
      backend_args (dict, optional): Arguments to instantiate the
          corresponding backend. Defaults to None.
      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. Defaults to None.
      sort_categories (bool): Whether sort categories in annotations. Only
          used for `Objects365V1Dataset`. Defaults to False.
      use_mp_eval (bool): Whether to use mul-processing evaluation
docstr: Process one batch of data samples and predictions. The processed
  results should be stored in ``self.results``, which will be used to
  compute the metrics when all batches have been processed.
  
  Args:
      data_batch (dict): A batch of data from the dataloader.
      data_samples (Sequence[dict]): A batch of data samples that
          contain annotations and predictions.
docstr_tok: ["Process","one","batch","of","data","samples","and","predictions",".","The","processed","results","should","be","stored","in","``","self.results","``",",","which","will","be","used","to","compute","the","metrics","when","all","batches","have","been","processed",".","Args",":","data_batch","(","dict",")",":","A","batch","of","data","from","the","dataloader",".","data_samples","(","Sequence","[","dict","]",")",":","A","batch","of","data","samples","that","contain","annotations","and","predictions","."]
code: def process(
      self, data_batch: dict, data_samples: Sequence[dict]
  ) -> None:
      """Process one batch of data samples and predictions. The processed
      results should be stored in ``self.results``, which will be used to
      compute the metrics when all batches have been processed.
  
      Args:
          data_batch (dict): A batch of data from the dataloader.
          data_samples (Sequence[dict]): A batch of data samples that
              contain annotations and predictions.
      """
      for data_sample in data_samples:
          result = dict()
          pred = data_sample["pred_instances"]
          result["img_id"] = data_sample["img_id"]
          result["bboxes"] = pred["bboxes"].cpu().numpy()
          result["scores"] = pred["scores"].cpu().numpy()
          result["labels"] = pred["labels"].cpu().numpy()
          # encode mask to RLE
          if "masks" in pred:
              result["masks"] = (
                  encode_mask_results(
                      pred["masks"].detach().cpu().numpy()
                  )
                  if isinstance(pred["masks"], torch.Tensor)
                  else pred["masks"]
              )
          # some detectors use different scores for bbox and mask
          if "mask_scores" in pred:
              result["mask_scores"] = pred["mask_scores"].cpu().numpy()
  
          # parse gt
          gt = dict()
          gt["width"] = data_sample["ori_shape"][1]
          gt["height"] = data_sample["ori_shape"][0]
          gt["img_id"] = data_sample["img_id"]
          if self._coco_api is None:
              # TODO: Need to refactor to support LoadAnnotations
              assert "instances" in data_sample, (
                  "ground truth is required for evaluation when "
                  "`ann_file` is not provided"
              )
              gt["anns"] = data_sample["instances"]
          # add converted result to the results list
          self.results.append((gt, result))
  
imports: import datetime
  import itertools
  import os.path
  import tempfile
  from collections import OrderedDict
  from typing import Dict, List, Optional, Sequence, Union
  import numpy
  import torch
  from mmengine.evaluator import BaseMetric
  from mmengine.fileio import dump, get_local_path, load
  from mmengine.logging import MMLogger
  from terminaltables import AsciiTable
  from mmdet.datasets.api_wrappers import COCO, COCOeval, COCOevalMP
  from mmdet.registry import METRICS
  from mmdet.structures.mask import encode_mask_results
  from ..functional import eval_recalls
label_desc: Use image node_id 6 for calling the CocoMetric obj's underlying member method code with example usage: obj.process(data_batch, data_samples) without return types