class_docstr: LVIS evaluation metric.
  
  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.
      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.
      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.
code: def __init__(
      self,
      ann_file: Optional[str] = None,
      metric: Union[str, List[str]] = "bbox",
      classwise: bool = False,
      proposal_nums: Sequence[int] = (100, 300, 1000),
      iou_thrs: Optional[Union[float, Sequence[float]]] = None,
      metric_items: Optional[Sequence[str]] = None,
      format_only: bool = False,
      outfile_prefix: Optional[str] = None,
      collect_device: str = "cpu",
      prefix: Optional[str] = None,
      file_client_args: dict = None,
      backend_args: dict = None,
  ) -> None:
      if lvis is None:
          raise RuntimeError(
              'Package lvis is not installed. Please run "pip install '
              'git+https://github.com/lvis-dataset/lvis-api.git".'
          )
      super().__init__(collect_device=collect_device, prefix=prefix)
      # coco evaluation metrics
      self.metrics = metric if isinstance(metric, list) else [metric]
      allowed_metrics = ["bbox", "segm", "proposal", "proposal_fast"]
      for metric in self.metrics:
          if metric not in allowed_metrics:
              raise KeyError(
                  "metric should be one of 'bbox', 'segm', 'proposal', "
                  f"'proposal_fast', but got {metric}."
              )
  
      # do class wise evaluation, default False
      self.classwise = classwise
  
      # proposal_nums used to compute recall or precision.
      self.proposal_nums = list(proposal_nums)
  
      # iou_thrs used to compute recall or precision.
      if iou_thrs is None:
          iou_thrs = np.linspace(
              0.5,
              0.95,
              int(np.round((0.95 - 0.5) / 0.05)) + 1,
              endpoint=True,
          )
      self.iou_thrs = iou_thrs
      self.metric_items = metric_items
      self.format_only = format_only
      if self.format_only:
          assert (
              outfile_prefix is not None
          ), "outfile_prefix must be not"
          "None when format_only is True, otherwise the result files will"
          "be saved to a temp directory which will be cleaned up at the end."
  
      self.outfile_prefix = outfile_prefix
      self.backend_args = backend_args
      if file_client_args is not None:
          raise RuntimeError(
              "The `file_client_args` is deprecated, "
              "please use `backend_args` instead, please refer to"
              "https://github.com/open-mmlab/mmdetection/blob/main/configs/_base_/datasets/coco_detection.py"  # noqa: E501
          )
  
      # if ann_file is not specified,
      # initialize lvis api with the converted dataset
      if ann_file is not None:
          with get_local_path(
              ann_file, backend_args=self.backend_args
          ) as local_path:
              self._lvis_api = LVIS(local_path)
      else:
          self._lvis_api = None
  
      # handle dataset lazy init
      self.cat_ids = None
      self.img_ids = None
  
imports: import itertools
  import logging
  import os.path
  import tempfile
  import warnings
  from collections import OrderedDict, defaultdict
  from typing import Dict, List, Optional, Sequence, Union
  import numpy
  import torch
  from mmengine.dist import all_gather_object, broadcast_object_list, is_main_process
  from mmengine.evaluator import BaseMetric
  from mmengine.evaluator.metric import _to_cpu
  from mmengine.fileio import get_local_path
  from mmengine.logging import MMLogger, print_log
  from terminaltables import AsciiTable
  from mmdet.registry import METRICS
  from mmdet.structures.mask import encode_mask_results
  from ..functional import eval_recalls
  from .coco_metric import CocoMetric
label_desc: Use image node_id 1 to create a new LVISMetric object from inherited base classes: CocoMetric with example: obj = LVISMetric(ann_file, metric, classwise, proposal_nums, iou_thrs, metric_items, format_only, outfile_prefix, collect_device, prefix, file_client_args, backend_args)