code: def __init__(
      self, conditions, predictions, labels=None, sample_weight=None
  ):
      # assert (len(predictions) == len(conditions))
      min_length = min(len(predictions), len(conditions))
      self.predictions = predictions[:min_length]
      self.conditions = conditions[:min_length]
  
      if labels is not None:
          self.label2idx = {
              label: idx for idx, label in enumerate(labels)
          }
          self.idx2label = {
              idx: label for idx, label in enumerate(labels)
          }
          labels = list(range(len(labels)))
      else:
          self.label2idx = {
              str(label): idx
              for idx, label in enumerate(
                  np.unique([self.predictions, self.conditions])
              )
          }
          self.idx2label = {
              idx: str(label)
              for idx, label in enumerate(
                  np.unique([self.predictions, self.conditions])
              )
          }
      self.cm = confusion_matrix(
          self.conditions,
          self.predictions,
          labels=labels,
          sample_weight=sample_weight,
      )
  
      # if labels is not None:
      #     self.labels_dict = {label: idx for idx, label in enumerate(labels)}
      # else:
      #     if conditions.dtype.char == 'S':  # it's an array of strings
      #         self.labels_dict = {str(label): idx for idx, label in
      #                             enumerate(np.unique([predictions, conditions]))}
      #     else:  # number
      #         max_label = np.concatenate([predictions, conditions]).max()
      #         self.labels_dict = {str(i): i for i in range(max_label + 1)}
      #         labels = [str(i) for i in range(max_label + 1)]
      # self.cm = confusion_matrix(conditions, predictions, labels, sample_weight)
  
      self.sum_predictions = np.sum(self.cm, axis=0)
      self.sum_conditions = np.sum(self.cm, axis=1)
      self.all = np.sum(self.cm)
  
imports: import logging
  from collections import OrderedDict
  import numpy
  from sklearn import metrics
  from sklearn.metrics import confusion_matrix
label_desc: Use image node_id 1 to create a new ConfusionMatrix object  with example: obj = ConfusionMatrix(conditions, predictions, labels, sample_weight)