class_docstr: Defines an evaluator for the LVIS dataset.
  
  This evaluator is usually used through a metric returned by
  :func:`make_lvis_metrics`.
  
  This mostly acts a wrapper around :class:`LVISEval` from the `lvis` library.
code: def evaluate(
      self, max_dets_per_image=None
  ) -> Optional[
      Union[Dict[str, Any], Tuple[Dict[str, Any], Dict[str, LVISEval]]]
  ]:
      all_preds, main_process = self.synchronize_between_processes()
      if main_process:
          if max_dets_per_image is None:
              max_dets_per_image = 300
  
          eval_imgs = [lvis_res["image_id"] for lvis_res in all_preds]
  
          gt_subset = LvisEvaluator._make_lvis_subset(
              self.lvis_gt, eval_imgs
          )
  
          for iou_type in self.iou_types:
              print("Evaluating for iou", iou_type)
              if iou_type == "segm":
                  # See:
                  # https://detectron2.readthedocs.io/en/latest/_modules/detectron2/evaluation/lvis_evaluation.html
                  lvis_results = copy.deepcopy(all_preds)
                  for c in lvis_results:
                      c.pop("bbox", None)
              else:
                  lvis_results = all_preds
  
              lvis_results = LVISResults(
                  gt_subset, lvis_results, max_dets=max_dets_per_image
              )
              lvis_eval = LVISEval(gt_subset, lvis_results, iou_type)
              lvis_eval.params.img_ids = list(set(eval_imgs))
              lvis_eval.run()
              self.lvis_eval_per_iou[iou_type] = lvis_eval
      else:
          self.lvis_eval_per_iou = None  # type: ignore
  
      if dist.is_initialized():
          dist.barrier()
  
      result_dict: Dict[str, Dict[str, Union[int, float]]] = dict()
      if self.lvis_eval_per_iou is not None:
          for iou, eval_data in self.lvis_eval_per_iou.items():
              result_dict[iou] = dict()
              for key in eval_data.results:
                  value = eval_data.results[key]
                  result_dict[iou][key] = value
  
      if main_process:
          return result_dict, self.lvis_eval_per_iou
      else:
          return None
  
imports: import copy
  import itertools
  import logging
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import pycocotools.mask
  import torch
  import torch.distributed
  from lvis import LVISEval, LVISResults, LVIS
  from avalanche.evaluation.metrics.detection import DetectionEvaluator, TCommonDetectionOutput
label_desc: Use image node_id 4 for calling the LvisEvaluator obj's underlying member method code with example usage: obj.evaluate(max_dets_per_image) and returns: result_dict,  self, None