class_docstr: The inference benchmark class. It will be statistical inference FPS,
  CUDA memory and CPU memory information.
  
  Args:
      cfg (mmengine.Config): config.
      checkpoint (str): Accept local filepath, URL, ``torchvision://xxx``,
          ``open-mmlab://xxx``.
      distributed (bool): distributed testing flag.
      is_fuse_conv_bn (bool): Whether to fuse conv and bn, this will
          slightly increase the inference speed.
      max_iter (int): maximum iterations of benchmark. Defaults to 2000.
      log_interval (int): interval of logging. Defaults to 50.
      num_warmup (int): Number of Warmup. Defaults to 5.
      logger (MMLogger, optional): Formatted logger used to record messages.
class_docstr_tok: ["The","inference","benchmark","class",".","It","will","be","statistical","inference","FPS",",","CUDA","memory","and","CPU","memory","information",".","Args",":","cfg","(","mmengine.Config",")",":","config",".","checkpoint","(","str",")",":","Accept","local","filepath",",","URL",",","``","torchvision",":","\/\/xxx","``",",","``","open-mmlab",":","\/\/xxx","``",".","distributed","(","bool",")",":","distributed","testing","flag",".","is_fuse_conv_bn","(","bool",")",":","Whether","to","fuse","conv","and","bn",",","this","will","slightly","increase","the","inference","speed",".","max_iter","(","int",")",":","maximum","iterations","of","benchmark",".","Defaults","to","2000.","log_interval","(","int",")",":","interval","of","logging",".","Defaults","to","50.","num_warmup","(","int",")",":","Number","of","Warmup",".","Defaults","to","5.","logger","(","MMLogger",",","optional",")",":","Formatted","logger","used","to","record","messages","."]
code: def __init__(
      self,
      cfg: Config,
      checkpoint: str,
      distributed: bool,
      is_fuse_conv_bn: bool,
      max_iter: int = 2000,
      log_interval: int = 50,
      num_warmup: int = 5,
      logger: Optional[MMLogger] = None,
  ):
      super().__init__(max_iter, log_interval, num_warmup, logger)
  
      assert (
          get_world_size() == 1
      ), "Inference benchmark does not allow distributed multi-GPU"
  
      self.cfg = copy.deepcopy(cfg)
      self.distributed = distributed
  
      if psutil is None:
          raise ImportError(
              "psutil is not installed, please install it by: "
              "pip install psutil"
          )
  
      self._process = psutil.Process()
      env_cfg = self.cfg.get("env_cfg")
      if env_cfg.get("cudnn_benchmark"):
          torch.backends.cudnn.benchmark = True
  
      mp_cfg: dict = env_cfg.get("mp_cfg", {})
      set_multi_processing(**mp_cfg, distributed=self.distributed)
  
      print_log("before build: ", self.logger)
      print_process_memory(self._process, self.logger)
  
      self.model = self._init_model(checkpoint, is_fuse_conv_bn)
  
      # Because multiple processes will occupy additional CPU resources,
      # FPS statistics will be more unstable when num_workers is not 0.
      # It is reasonable to set num_workers to 0.
      dataloader_cfg = cfg.test_dataloader
      dataloader_cfg["num_workers"] = 0
      dataloader_cfg["batch_size"] = 1
      dataloader_cfg["persistent_workers"] = False
      self.data_loader = Runner.build_dataloader(dataloader_cfg)
  
      print_log("after build: ", self.logger)
      print_process_memory(self._process, self.logger)
  
imports: import copy
  import time
  from functools import partial
  from typing import List, Optional, Union
  import numpy
  import torch
  import torch.nn
  from mmcv.cnn import fuse_conv_bn
  from mmengine import MMLogger
  from mmengine.config import Config
  from mmengine.device import get_max_cuda_memory
  from mmengine.dist import get_world_size
  from mmengine.runner import Runner, load_checkpoint
  from mmengine.utils.dl_utils import set_multi_processing
  from torch.nn.parallel import DistributedDataParallel
  from mmdet.registry import DATASETS, MODELS
label_desc: Use image node_id 1 to create a new InferenceBenchmark object from inherited base classes: BaseBenchmark with example: obj = InferenceBenchmark(cfg, checkpoint, distributed, is_fuse_conv_bn, max_iter, log_interval, num_warmup, logger)