code: def plot_confusion_matrix(
      confusion_matrix,
      labels,
      save_dir=None,
      show=True,
      title="Normalized Confusion Matrix",
      color_theme="plasma",
  ):
      """Draw confusion matrix with matplotlib.
  
      Args:
          confusion_matrix (ndarray): The confusion matrix.
          labels (list[str]): List of class names.
          save_dir (str|optional): If set, save the confusion matrix plot to the
              given path. Default: None.
          show (bool): Whether to show the plot. Default: True.
          title (str): Title of the plot. Default: `Normalized Confusion Matrix`.
          color_theme (str): Theme of the matrix color map. Default: `plasma`.
      """
      # normalize the confusion matrix
      per_label_sums = confusion_matrix.sum(axis=1)[:, np.newaxis]
      confusion_matrix = (
          confusion_matrix.astype(np.float32) / per_label_sums * 100
      )
  
      num_classes = len(labels)
      fig, ax = plt.subplots(
          figsize=(0.5 * num_classes, 0.5 * num_classes * 0.8), dpi=180
      )
      cmap = plt.get_cmap(color_theme)
      im = ax.imshow(confusion_matrix, cmap=cmap)
      plt.colorbar(mappable=im, ax=ax)
  
      title_font = {"weight": "bold", "size": 12}
      ax.set_title(title, fontdict=title_font)
      label_font = {"size": 10}
      plt.ylabel("Ground Truth Label", fontdict=label_font)
      plt.xlabel("Prediction Label", fontdict=label_font)
  
      # draw locator
      xmajor_locator = MultipleLocator(1)
      xminor_locator = MultipleLocator(0.5)
      ax.xaxis.set_major_locator(xmajor_locator)
      ax.xaxis.set_minor_locator(xminor_locator)
      ymajor_locator = MultipleLocator(1)
      yminor_locator = MultipleLocator(0.5)
      ax.yaxis.set_major_locator(ymajor_locator)
      ax.yaxis.set_minor_locator(yminor_locator)
  
      # draw grid
      ax.grid(True, which="minor", linestyle="-")
  
      # draw label
      ax.set_xticks(np.arange(num_classes))
      ax.set_yticks(np.arange(num_classes))
      ax.set_xticklabels(labels)
      ax.set_yticklabels(labels)
  
      ax.tick_params(
          axis="x",
          bottom=False,
          top=True,
          labelbottom=False,
          labeltop=True,
      )
      plt.setp(
          ax.get_xticklabels(),
          rotation=45,
          ha="left",
          rotation_mode="anchor",
      )
  
      # draw confution matrix value
      for i in range(num_classes):
          for j in range(num_classes):
              ax.text(
                  j,
                  i,
                  "{}%".format(
                      int(confusion_matrix[i, j])
                      if not np.isnan(confusion_matrix[i, j])
                      else -1
                  ),
                  ha="center",
                  va="center",
                  color="w",
                  size=7,
              )
  
      ax.set_ylim(len(confusion_matrix) - 0.5, -0.5)  # matplotlib>3.1.1
  
      fig.tight_layout()
      if save_dir is not None:
          plt.savefig(
              os.path.join(save_dir, "confusion_matrix.png"),
              format="png",
          )
      if show:
          plt.show()
  
file_path: mmdetection/tools/analysis_tools/confusion_matrix.py
imports: import argparse
  import os
  import matplotlib.pyplot
  import numpy
  from matplotlib.ticker import MultipleLocator
  from mmcv.ops import nms
  from mmengine import Config, DictAction
  from mmengine.fileio import load
  from mmengine.registry import init_default_scope
  from mmengine.utils import ProgressBar
  from mmdet.evaluation import bbox_overlaps
  from mmdet.registry import DATASETS
  from mmdet.utils import replace_cfg_vals, update_data_root
label_desc: Use image node_id 4 for calling a global function with example usage: plot_confusion_matrix(confusion_matrix, labels, save_dir, show, title, color_theme) without return types