class_docstr: Detection Visualization Hook. Used to visualize validation and testing
  process prediction results.
  
  In the testing phase:
  
  1. If ``show`` is True, it means that only the prediction results are
      visualized without storing data, so ``vis_backends`` needs to
      be excluded.
  2. If ``test_out_dir`` is specified, it means that the prediction results
      need to be saved to ``test_out_dir``. In order to avoid vis_backends
      also storing data, so ``vis_backends`` needs to be excluded.
  3. ``vis_backends`` takes effect if the user does not specify ``show``
      and `test_out_dir``. You can set ``vis_backends`` to WandbVisBackend or
      TensorboardVisBackend to store the prediction result in Wandb or
      Tensorboard.
  
  Args:
      draw (bool): whether to draw prediction results. If it is False,
          it means that no drawing will be done. Defaults to False.
      interval (int): The interval of visualization. Defaults to 50.
      score_thr (float): The threshold to visualize the bboxes
          and masks. Defaults to 0.3.
      show (bool): Whether to display the drawn image. Default to False.
      wait_time (float): The interval of show (s). Defaults to 0.
      test_out_dir (str, optional): directory where painted images
          will be saved in testing process.
      backend_args (dict, optional): Arguments to instantiate the
          corresponding backend. Defaults to None.
code: def __init__(
      self,
      draw: bool = False,
      interval: int = 50,
      score_thr: float = 0.3,
      show: bool = False,
      wait_time: float = 0.0,
      test_out_dir: Optional[str] = None,
      backend_args: dict = None,
  ):
      self._visualizer: Visualizer = Visualizer.get_current_instance()
      self.interval = interval
      self.score_thr = score_thr
      self.show = show
      if self.show:
          # No need to think about vis backends.
          self._visualizer._vis_backends = {}
          warnings.warn(
              "The show is True, it means that only "
              "the prediction results are visualized "
              "without storing data, so vis_backends "
              "needs to be excluded."
          )
  
      self.wait_time = wait_time
      self.backend_args = backend_args
      self.draw = draw
      self.test_out_dir = test_out_dir
      self._test_index = 0
  
imports: import os.path
  import warnings
  from typing import Optional, Sequence
  import mmcv
  import numpy
  from mmengine.fileio import get
  from mmengine.hooks import Hook
  from mmengine.runner import Runner
  from mmengine.utils import mkdir_or_exist
  from mmengine.visualization import Visualizer
  from mmdet.datasets.samplers import TrackImgSampler
  from mmdet.registry import HOOKS
  from mmdet.structures import DetDataSample, TrackDataSample
  from mmdet.structures.bbox import BaseBoxes
  from mmdet.visualization.palette import _get_adaptive_scales
label_desc: Use image node_id 1 to create a new DetVisualizationHook object from inherited base classes: Hook with example: obj = DetVisualizationHook(draw, interval, score_thr, show, wait_time, test_out_dir, backend_args)