code: def plot_hist(
      writer,
      cmtx,
      num_classes,
      k=10,
      global_step=None,
      subset_ids=None,
      class_names=None,
      figsize=None,
  ):
      """
      Given all predictions and all true labels, plot histograms of top-k most
      frequently predicted classes for each true class.
  
      Args:
          writer (SummaryWriter object): a tensorboard SummaryWriter object.
          cmtx (ndarray): confusion matrix.
          num_classes (int): total number of classes.
          k (int): top k to plot histograms.
          global_step (Optional[int]): current step.
          subset_ids (list of ints, optional): class indices to plot histogram.
          mapping (list of strings): names of all classes.
          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 subset_ids is None:
              subset_ids = set(range(num_classes))
          else:
              subset_ids = set(subset_ids)
          # If class names are not provided, use their indices as names.
          if class_names is None:
              class_names = list(range(num_classes))
  
          for i in subset_ids:
              pred = cmtx[i]
              hist = vis_utils.plot_topk_histogram(
                  class_names[i],
                  torch.Tensor(pred),
                  k,
                  class_names,
                  figsize=figsize,
              )
              writer.add_figure(
                  tag="Top {} predictions by classes/{}".format(
                      k, class_names[i]
                  ),
                  figure=hist,
                  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 2 for calling a global function with example usage: plot_hist(writer, cmtx, num_classes, k, global_step, subset_ids, class_names, figsize) without return types