code: def get_confusion_matrix(
      matches: Sequence[Event], class_labels: Optional[Set] = None
  ) -> np.ndarray:
      labels = {match.data["expected"] for match in matches}
      if class_labels is None:
          labels = {label: i for i, label in enumerate(sorted(labels))}
      else:
          assert labels.issubset(class_labels)
          labels = {label: i for i, label in enumerate(class_labels)}
      result = np.zeros((len(labels), len(labels) + 1), dtype=int)
      for match in matches:
          i = labels[match.data["expected"]]
          j = labels.get(match.data["picked"], len(labels))
          result[i, j] += 1
      return result
  
file_path: evals/evals/metrics.py
imports: import random
  from typing import Optional, Sequence, Set
  import numpy
  from evals.record import Event
label_desc: Use image node_id 3 for calling a global function with example usage: get_confusion_matrix(matches, class_labels) and returns: result