code: def plot_confusion_matrix(
      confusion_matrix,
      labels,
      show_values=True,
      show_colorbar=True,
      cmap=None,
      title=None,
      xticks_rotation=45.0,
      values_format=None,
      ax=None,
      figsize=None,
  ):
      """Plots a confusion matrix.
  
      Args:
          confusion_matrix: a ``num_true x num_preds`` confusion matrix
          labels: a ``max(num_true, num_preds)`` array-like of class labels
          show_values (True): whether to show counts in the confusion matrix
              cells
          show_colorbar (True): whether to show a colorbar
          cmap (None): a colormap recognized by ``matplotlib``
          title (None): a title for the plot
          xticks_rotation (45.0): a rotation for the x-tick labels. Can be
              numeric degrees, "vertical", "horizontal", or None
          values_format (None): a format string like ``".2g"`` or ``"d"`` to use
              to format the cell counts
          ax (None): a matplotlib axis to plot in
          figsize (None): a ``(width, height)`` for the figure, in inches
  
      Returns:
          a matplotlib figure
      """
      if ax is None:
          fig, ax = plt.subplots()
      else:
          fig = ax.figure
  
      confusion_matrix = np.asarray(confusion_matrix)
      nrows = confusion_matrix.shape[0]
      ncols = confusion_matrix.shape[1]
  
      if cmap is None:
          cmap = _DEFAULT_CONTINUOUS_COLORSCALE
  
      im = ax.imshow(
          confusion_matrix, interpolation="nearest", cmap=cmap
      )
  
      if show_values:
          # Print text with appropriate color depending on background
          cmap_min = im.cmap(0)
          cmap_max = im.cmap(256)
          thresh = (
              confusion_matrix.max() + confusion_matrix.min()
          ) / 2.0
  
          for i, j in itertools.product(range(nrows), range(ncols)):
              color = (
                  cmap_max
                  if confusion_matrix[i, j] < thresh
                  else cmap_min
              )
  
              if values_format is None:
                  text_cm = format(confusion_matrix[i, j], ".2g")
                  if confusion_matrix.dtype.kind != "f":
                      text_d = format(confusion_matrix[i, j], "d")
                      if len(text_d) < len(text_cm):
                          text_cm = text_d
              else:
                  text_cm = format(
                      confusion_matrix[i, j], values_format
                  )
  
              ax.text(
                  j, i, text_cm, ha="center", va="center", color=color
              )
  
      ax.set(
          xticks=np.arange(ncols),
          yticks=np.arange(nrows),
          xticklabels=labels[:ncols],
          yticklabels=labels[:nrows],
          xlabel="Predicted label",
          ylabel="True label",
      )
      ax.set_ylim((nrows - 0.5, -0.5))  # flip axis
  
      if xticks_rotation is not None:
          plt.setp(ax.get_xticklabels(), rotation=xticks_rotation)
  
      if show_colorbar:
          divider = make_axes_locatable(ax)
          cax = divider.append_axes("right", size="5%", pad=0.1)
          fig.colorbar(im, cax=cax)
  
      if figsize is not None:
          fig.set_size_inches(*figsize)
  
      if title is not None:
          fig.suptitle(title)
  
      plt.tight_layout()
  
      return fig
  
imports: import itertools
  import logging
  import numpy
  import matplotlib
  from matplotlib.widgets import Button, LassoSelector
  from matplotlib.path import Path
  import matplotlib.pyplot
  from mpl_toolkits.axes_grid1 import make_axes_locatable
  from mpl_toolkits.axes_grid1.inset_locator import InsetPosition
  from mpl_toolkits.mplot3d import Axes3D
  import sklearn.metrics.pairwise
  import sklearn.metrics
  import eta.core.utils
  import fiftyone.core.context
  import fiftyone.core.utils
  from .base import InteractivePlot
  from .utils import best_fit_line, load_button_icon, parse_lines_inputs, parse_locations, parse_scatter_inputs
label_desc: Use image node_id 1 for calling a global function with example usage: plot_confusion_matrix(confusion_matrix, labels, show_values, show_colorbar, cmap, title, xticks_rotation, values_format, ax, figsize) and returns: fig