code: def _pair_confusion(cm):
      pair_confusion_matrix = {
          i: collections.defaultdict(int) for i in range(2)
      }
  
      sum_squares = 0
      false_positives = 0
      false_negatives = 0
  
      for i in cm.classes:
          for j in cm.classes:
              sum_squares += cm[i][j] * cm[i][j]
              false_positives += cm[i][j] * cm.sum_col[j]
              false_negatives += cm[j][i] * cm.sum_row[j]
  
      true_positives = sum_squares - cm.n_samples
  
      false_positives -= sum_squares
  
      false_negatives -= sum_squares
  
      true_negatives = (
          cm.n_samples * cm.n_samples
          - (false_positives + false_negatives)
          - sum_squares
      )
  
      pair_confusion_matrix[0][0] = true_negatives
      pair_confusion_matrix[0][1] = false_positives
      pair_confusion_matrix[1][0] = false_negatives
      pair_confusion_matrix[1][1] = true_positives
  
      return pair_confusion_matrix
  
file_path: river/river/metrics/rand.py
imports: from __future__ import annotations
  import collections
  from river import metrics
label_desc: Use image node_id 1 for calling a global function with example usage: _pair_confusion(cm) and returns: pair_confusion_matrix