class_docstr: Dump proposals pseudo metric.
  
  Args:
      output_dir (str): The root directory for ``proposals_file``.
          Defaults to ''.
      proposals_file (str): Proposals file path. Defaults to 'proposals.pkl'.
      num_max_proposals (int, optional): Maximum number of proposals to dump.
          If not specified, all proposals will be dumped.
      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.
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: Sequence[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:
          pred = data_sample["pred_instances"]
          # `bboxes` is sorted by `scores`
          ranked_scores, rank_inds = pred["scores"].sort(
              descending=True
          )
          ranked_bboxes = pred["bboxes"][rank_inds, :]
  
          ranked_bboxes = ranked_bboxes.cpu().numpy()
          ranked_scores = ranked_scores.cpu().numpy()
  
          pred_instance = InstanceData()
          pred_instance.bboxes = ranked_bboxes
          pred_instance.scores = ranked_scores
          if self.num_max_proposals is not None:
              pred_instance = pred_instance[: self.num_max_proposals]
  
          img_path = data_sample["img_path"]
          # `file_name` is the key to obtain the proposals from the
          # `proposals_list`.
          file_name = osp.join(
              osp.split(osp.split(img_path)[0])[-1],
              osp.split(img_path)[-1],
          )
          result = {file_name: pred_instance}
          self.results.append(result)
  
file_path: mmdetection/mmdet/evaluation/metrics/dump_proposals_metric.py
imports: import os
  import os.path
  from typing import Optional, Sequence
  from mmengine.dist import is_main_process
  from mmengine.evaluator import BaseMetric
  from mmengine.fileio import dump
  from mmengine.logging import MMLogger
  from mmengine.structures import InstanceData
  from mmdet.registry import METRICS
label_desc: Use image node_id 2 for calling the DumpProposals obj's underlying member method code with example usage: obj.process(data_batch, data_samples) without return types