code: def plot_confusion_matrix(
      cmtx, num_classes, class_names=None, figsize=None
  ):
      """
      A function to create a colored and labeled confusion matrix matplotlib figure
      given true labels and preds.
      Args:
          cmtx (ndarray): confusion matrix.
          num_classes (int): total number of classes.
          class_names (Optional[list of strs]): a list of class names.
          figsize (Optional[float, float]): the figure size of the confusion matrix.
              If None, default to [6.4, 4.8].
  
      Returns:
          img (figure): matplotlib figure.
      """
      if class_names is None or type(class_names) != list:
          class_names = [str(i) for i in range(num_classes)]
  
      figure = plt.figure(figsize=figsize)
      plt.imshow(cmtx, interpolation="nearest", cmap=plt.cm.Blues)
      plt.title("Confusion matrix")
      plt.colorbar()
      tick_marks = np.arange(len(class_names))
      plt.xticks(tick_marks, class_names, rotation=45)
      plt.yticks(tick_marks, class_names)
  
      # Use white text if squares are dark; otherwise black.
      threshold = cmtx.max() / 2.0
      for i, j in itertools.product(
          range(cmtx.shape[0]), range(cmtx.shape[1])
      ):
          color = "white" if cmtx[i, j] > threshold else "black"
          plt.text(
              j,
              i,
              format(cmtx[i, j], ".2f") if cmtx[i, j] != 0 else ".",
              horizontalalignment="center",
              color=color,
          )
  
      plt.tight_layout()
      plt.ylabel("True label")
      plt.xlabel("Predicted label")
  
      return figure
  
imports: import itertools
  import numpy
  import matplotlib.pyplot
  import torch
  from sklearn.metrics import confusion_matrix
  import slowfast.utils.logging
  from slowfast.datasets.utils import pack_pathway_output, tensor_normalize
label_desc: Use image node_id 2 for calling a global function with example usage: plot_confusion_matrix(cmtx, num_classes, class_names, figsize) and returns: figure