code: def _to_pyplot(normalize=False, title="Confusion matrix", cmap=None):
      """
      This function modified to plots the ConfusionMatrix object.
      Normalization can be applied by setting `normalize=True`.
  
      Code Reference :
      http://scikit-learn.org/stable/auto_examples/model_selection/plot_confusion_matrix.html
  
      """
      import matplotlib.pyplot as plt
      import itertools
      import numpy as np
  
      if cmap is None:
          cmap = plt.cm.Blues
  
      def handler(cm, state):
          string_state = {str(key): state[key] for key in state.keys()}
          plt_cm = []
          for i in cm.classes:
              row = []
              for j in cm.classes:
                  row.append(cm.table[i][j])
              plt_cm.append(row)
          plt_cm = np.array(plt_cm)
          if normalize:
              plt_cm = (
                  plt_cm.astype("float")
                  / plt_cm.sum(axis=1)[:, np.newaxis]
              )
          plt.imshow(plt_cm, interpolation="nearest", cmap=cmap)
          plt.title(title.format(**string_state))
          plt.colorbar()
          tick_marks = np.arange(len(cm.classes))
          plt.xticks(tick_marks, cm.classes, rotation=45)
          plt.yticks(tick_marks, cm.classes)
  
          fmt = ".2f" if normalize else "d"
          thresh = plt_cm.max() / 2.0
          for i, j in itertools.product(
              range(plt_cm.shape[0]), range(plt_cm.shape[1])
          ):
              plt.text(
                  j,
                  i,
                  format(plt_cm[i, j], fmt),
                  horizontalalignment="center",
                  color="white" if plt_cm[i, j] > thresh else "black",
              )
  
          plt.tight_layout()
          plt.ylabel("Actual")
          plt.xlabel("Predict")
          plt.show()
  
      return handler
  
imports: from __future__ import print_function
  import torch
  import torchbearer
  from torchbearer import Callback
  from torchbearer.bases import cite
  from torchbearer.metrics import EpochLambda, MetricList
label_desc: Use image node_id 1 for calling a global function with example usage: _to_pyplot(normalize, title, cmap) and returns: handler