code: def add_confusion_matrix(
      writer,
      cmtx,
      num_classes,
      global_step=None,
      subset_ids=None,
      class_names=None,
      tag="Confusion Matrix",
      figsize=None,
  ):
      """
      Calculate and plot confusion matrix to a SummaryWriter.
      Args:
          writer (SummaryWriter): the SummaryWriter to write the matrix to.
          cmtx (ndarray): confusion matrix.
          num_classes (int): total number of classes.
          global_step (Optional[int]): current step.
          subset_ids (list of ints): a list of label indices to keep.
          class_names (list of strs, optional): a list of all class names.
          tag (str or list of strs): name(s) of the confusion matrix image.
          figsize (Optional[float, float]): the figure size of the confusion matrix.
              If None, default to [6.4, 4.8].
  
      """
      if subset_ids is None or len(subset_ids) != 0:
          # If class names are not provided, use class indices as class names.
          if class_names is None:
              class_names = [str(i) for i in range(num_classes)]
          # If subset is not provided, take every classes.
          if subset_ids is None:
              subset_ids = list(range(num_classes))
  
          sub_cmtx = cmtx[subset_ids, :][:, subset_ids]
          sub_names = [class_names[j] for j in subset_ids]
  
          sub_cmtx = vis_utils.plot_confusion_matrix(
              sub_cmtx,
              num_classes=len(subset_ids),
              class_names=sub_names,
              figsize=figsize,
          )
          # Add the confusion matrix image to writer.
          writer.add_figure(
              tag=tag, figure=sub_cmtx, global_step=global_step
          )
  
imports: import logging
  import math
  import os
  import matplotlib.pyplot
  import torch
  from torch.utils.tensorboard import SummaryWriter
  from torchvision.utils import make_grid
  import slowfast.utils.logging
  import slowfast.visualization.utils
  from slowfast.utils.misc import get_class_names
label_desc: Use image node_id 1 for calling a global function with example usage: add_confusion_matrix(writer, cmtx, num_classes, global_step, subset_ids, class_names, tag, figsize) without return types