docstr: Args:
      num_classes (int): total number of classes.
      class_names (dict): Dict mapping classID to name.
      top_k (int): number of top predicted classes to plot.
      colormap (str): the colormap to choose color for class labels from.
          See https://matplotlib.org/tutorials/colors/colormaps.html
      thres (float): threshold for picking predicted classes to visualize.
      lower_thres (Optional[float]): If `common_class_names` if given,
          this `lower_thres` will be applied to uncommon classes and
          `thres` will be applied to classes in `common_class_names`.
      common_class_names (Optional[list of str]): list of common class names
          to apply `thres`. Class names not included in `common_class_names` will
          have `lower_thres` as a threshold. If None, all classes will have
          `thres` as a threshold. This is helpful for model trained on
          highly imbalanced dataset.
      mode (str): Supported modes are {"top-k", "thres"}.
          This is used for choosing predictions for visualization.
docstr_tok: ["Args",":","num_classes","(","int",")",":","total","number","of","classes",".","class_names","(","dict",")",":","Dict","mapping","classID","to","name",".","top_k","(","int",")",":","number","of","top","predicted","classes","to","plot",".","colormap","(","str",")",":","the","colormap","to","choose","color","for","class","labels","from",".","See","https",":","\/\/matplotlib.org\/tutorials\/colors\/colormaps.html","thres","(","float",")",":","threshold","for","picking","predicted","classes","to","visualize",".","lower_thres","(","Optional","[","float","]",")",":","If","`","common_class_names","`","if","given",",","this","`","lower_thres","`","will","be","applied","to","uncommon","classes","and","`","thres","`","will","be","applied","to","classes","in","`","common_class_names","`",".","common_class_names","(","Optional","[","list","of","str","]",")",":","list","of","common","class","names","to","apply","`","thres","`",".","Class","names","not","included","in","`","common_class_names","`","will","have","`","lower_thres","`","as","a","threshold",".","If","None",",","all","classes","will","have","`","thres","`","as","a","threshold",".","This","is","helpful","for","model","trained","on","highly","imbalanced","dataset",".","mode","(","str",")",":","Supported","modes","are","{","``","top-k","''",",","``","thres","''","}",".","This","is","used","for","choosing","predictions","for","visualization","."]
code: def __init__(
      self,
      num_classes: int,
      class_names: Dict,
      top_k: int = 1,
      colormap: str = "rainbow",
      thres: float = 0.7,
      lower_thres: float = 0.3,
      common_class_names: Optional[List[str]] = None,
      mode: str = "top-k",
  ) -> None:
      """
      Args:
          num_classes (int): total number of classes.
          class_names (dict): Dict mapping classID to name.
          top_k (int): number of top predicted classes to plot.
          colormap (str): the colormap to choose color for class labels from.
              See https://matplotlib.org/tutorials/colors/colormaps.html
          thres (float): threshold for picking predicted classes to visualize.
          lower_thres (Optional[float]): If `common_class_names` if given,
              this `lower_thres` will be applied to uncommon classes and
              `thres` will be applied to classes in `common_class_names`.
          common_class_names (Optional[list of str]): list of common class names
              to apply `thres`. Class names not included in `common_class_names` will
              have `lower_thres` as a threshold. If None, all classes will have
              `thres` as a threshold. This is helpful for model trained on
              highly imbalanced dataset.
          mode (str): Supported modes are {"top-k", "thres"}.
              This is used for choosing predictions for visualization.
  
      """
      assert mode in [
          "top-k",
          "thres",
      ], "Mode {} is not supported.".format(mode)
      self.mode = mode
      self.num_classes = num_classes
      self.class_names = class_names
      self.top_k = top_k
      self.thres = thres
      self.lower_thres = lower_thres
  
      if mode == "thres":
          self._get_thres_array(common_class_names=common_class_names)
  
      self.color_map = plt.get_cmap(colormap)
  
imports: from __future__ import annotations
  import itertools
  import logging
  from types import SimpleNamespace
  from typing import Dict, List, Optional, Tuple, Union
  import matplotlib.pyplot
  import numpy
  import torch
  from detectron2.utils.visualizer import Visualizer
label_desc: Use image node_id 1 to create a new VideoVisualizer object  with example: obj = VideoVisualizer(num_classes, class_names, top_k, colormap, thres, lower_thres, common_class_names, mode)