code: def plot_topk_histogram(
      tag, array, k=10, class_names=None, figsize=None
  ):
      """
      Plot histogram of top-k value from the given array.
      Args:
          tag (str): histogram title.
          array (tensor): a tensor to draw top k value from.
          k (int): number of top values to draw from array.
              Defaut to 10.
          class_names (list of strings, optional):
              a list of names for values in array.
          figsize (Optional[float, float]): the figure size of the confusion matrix.
              If None, default to [6.4, 4.8].
      Returns:
          fig (matplotlib figure): a matplotlib figure of the histogram.
      """
      val, ind = torch.topk(array, k)
  
      fig = plt.Figure(figsize=figsize, facecolor="w", edgecolor="k")
  
      ax = fig.add_subplot(1, 1, 1)
  
      if class_names is None:
          class_names = [str(i) for i in ind]
      else:
          class_names = [class_names[i] for i in ind]
  
      tick_marks = np.arange(k)
      width = 0.75
      ax.bar(
          tick_marks,
          val,
          width,
          color="orange",
          tick_label=class_names,
          edgecolor="w",
          linewidth=1,
      )
  
      ax.set_xlabel("Candidates")
      ax.set_xticks(tick_marks)
      ax.set_xticklabels(class_names, rotation=-45, ha="center")
      ax.xaxis.set_label_position("bottom")
      ax.xaxis.tick_bottom()
  
      y_tick = np.linspace(0, 1, num=10)
      ax.set_ylabel("Frequency")
      ax.set_yticks(y_tick)
      y_labels = [format(i, ".1f") for i in y_tick]
      ax.set_yticklabels(y_labels, ha="center")
  
      for i, v in enumerate(val.numpy()):
          ax.text(
              i - 0.1,
              v + 0.03,
              format(v, ".2f"),
              color="orange",
              fontweight="bold",
          )
  
      ax.set_title(tag)
  
      fig.set_tight_layout(True)
  
      return fig
  
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 3 for calling a global function with example usage: plot_topk_histogram(tag, array, k, class_names, figsize) and returns: fig