class_docstr: Tracking Local Visualizer for the MOT, VIS tasks.
  
  Args:
      name (str): Name of the instance. Defaults to 'visualizer'.
      image (np.ndarray, optional): the origin image to draw. The format
          should be RGB. Defaults to None.
      vis_backends (list, optional): Visual backend config list.
          Defaults to None.
      save_dir (str, optional): Save file dir for all storage backends.
          If it is None, the backend storage will not save any data.
      line_width (int, float): The linewidth of lines.
          Defaults to 3.
      alpha (int, float): The transparency of bboxes or mask.
              Defaults to 0.8.
class_docstr_tok: ["Tracking","Local","Visualizer","for","the","MOT",",","VIS","tasks",".","Args",":","name","(","str",")",":","Name","of","the","instance",".","Defaults","to","'visualizer","'",".","image","(","np.ndarray",",","optional",")",":","the","origin","image","to","draw",".","The","format","should","be","RGB",".","Defaults","to","None",".","vis_backends","(","list",",","optional",")",":","Visual","backend","config","list",".","Defaults","to","None",".","save_dir","(","str",",","optional",")",":","Save","file","dir","for","all","storage","backends",".","If","it","is","None",",","the","backend","storage","will","not","save","any","data",".","line_width","(","int",",","float",")",":","The","linewidth","of","lines",".","Defaults","to","3.","alpha","(","int",",","float",")",":","The","transparency","of","bboxes","or","mask",".","Defaults","to","0.8","."]
docstr: Draw instances of GT or prediction.
  
  Args:
      image (np.ndarray): The image to draw.
      instances (:obj:`InstanceData`): Data structure for
          instance-level annotations or predictions.
  Returns:
      np.ndarray: the drawn image which channel is RGB.
docstr_tok: ["Draw","instances","of","GT","or","prediction",".","Args",":","image","(","np.ndarray",")",":","The","image","to","draw",".","instances","(",":","obj",":","`","InstanceData","`",")",":","Data","structure","for","instance-level","annotations","or","predictions",".","Returns",":","np.ndarray",":","the","drawn","image","which","channel","is","RGB","."]
code: def _draw_instances(
      self, image: np.ndarray, instances: InstanceData
  ) -> np.ndarray:
      """Draw instances of GT or prediction.
  
      Args:
          image (np.ndarray): The image to draw.
          instances (:obj:`InstanceData`): Data structure for
              instance-level annotations or predictions.
      Returns:
          np.ndarray: the drawn image which channel is RGB.
      """
      self.set_image(image)
      classes = self.dataset_meta.get("classes", None)
  
      # get colors and texts
      # for the MOT and VIS tasks
      colors = [random_color(_id) for _id in instances.instances_id]
      categories = [
          classes[label] if classes is not None else f"cls{label}"
          for label in instances.labels
      ]
      if "scores" in instances:
          texts = [
              f"{category_name}\n{instance_id} | {score:.2f}"
              for category_name, instance_id, score in zip(
                  categories, instances.instances_id, instances.scores
              )
          ]
      else:
          texts = [
              f"{category_name}\n{instance_id}"
              for category_name, instance_id in zip(
                  categories, instances.instances_id
              )
          ]
  
      # draw bboxes and texts
      if "bboxes" in instances:
          # draw bboxes
          bboxes = instances.bboxes.clone()
          self.draw_bboxes(
              bboxes,
              edge_colors=colors,
              alpha=self.alpha,
              line_widths=self.line_width,
          )
          # draw texts
          if texts is not None:
              positions = bboxes[:, :2] + self.line_width
              areas = (bboxes[:, 3] - bboxes[:, 1]) * (
                  bboxes[:, 2] - bboxes[:, 0]
              )
              scales = _get_adaptive_scales(areas.cpu().numpy())
              for i, pos in enumerate(positions):
                  self.draw_texts(
                      texts[i],
                      pos,
                      colors="black",
                      font_sizes=int(13 * scales[i]),
                      bboxes=[
                          {
                              "facecolor": [c / 255 for c in colors[i]],
                              "alpha": 0.8,
                              "pad": 0.7,
                              "edgecolor": "none",
                          }
                      ],
                  )
  
      # draw masks
      if "masks" in instances:
          masks = instances.masks
          polygons = []
          for i, mask in enumerate(masks):
              contours, _ = bitmap_to_polygon(mask)
              polygons.extend(contours)
          self.draw_polygons(
              polygons, edge_colors="w", alpha=self.alpha
          )
          self.draw_binary_masks(
              masks, colors=colors, alphas=self.alpha
          )
  
      return self.get_image()
  
imports: from typing import Dict, List, Optional, Tuple, Union
  import cv2
  import mmcv
  import numpy
  import torch
  from mmengine.dist import master_only
  from mmengine.structures import InstanceData, PixelData
  from mmengine.visualization import Visualizer
  from ..evaluation import INSTANCE_OFFSET
  from ..registry import VISUALIZERS
  from ..structures import DetDataSample
  from ..structures.mask import BitmapMasks, PolygonMasks, bitmap_to_polygon
  from .palette import _get_adaptive_scales, get_palette, jitter_color
label_desc: Use image node_id 2 for calling the TrackLocalVisualizer obj's underlying member method code with example usage: obj._draw_instances(image, instances) and returns: self