code: def _compute_confusion_matrix(
      ytrue,
      ypred,
      labels,
      weights=None,
      ytrue_ids=None,
      ypred_ids=None,
      tabulate_ids=False,
  ):
      ytrue = np.asarray(ytrue).flatten()
      ypred = np.asarray(ypred).flatten()
      labels = np.asarray(labels)
  
      if weights is None:
          weights = np.ones(ytrue.size, dtype=int)
      else:
          weights = np.asarray(weights).flatten()
  
      if weights.dtype.kind in {"i", "u", "b"}:
          dtype = np.int64
      else:
          dtype = np.float64
  
      num_labels = labels.size
  
      confusion_matrix = np.zeros((num_labels, num_labels), dtype=dtype)
  
      if tabulate_ids:
          ids = np.empty((num_labels, num_labels), dtype=object)
          for i in range(num_labels):
              for j in range(num_labels):
                  ids[i, j] = []
      else:
          ytrue_ids = None
          ypred_ids = None
          ids = None
  
      if num_labels == 0 or ytrue.size == 0:
          return confusion_matrix, ids
  
      labels_to_inds = {label: idx for idx, label in enumerate(labels)}
      ypred = np.array([labels_to_inds.get(y, -1) for y in ypred])
      ytrue = np.array([labels_to_inds.get(y, -1) for y in ytrue])
  
      found = np.logical_and(ypred >= 0, ytrue >= 0)
      ypred = ypred[found]
      ytrue = ytrue[found]
      weights = weights[found]
  
      if ytrue_ids is not None:
          ytrue_ids = ytrue_ids[found]
      else:
          ytrue_ids = itertools.repeat(None)
  
      if ypred_ids is not None:
          ypred_ids = ypred_ids[found]
      else:
          ypred_ids = itertools.repeat(None)
  
      for yt, yp, w, it, ip in zip(
          ytrue, ypred, weights, ytrue_ids, ypred_ids
      ):
          confusion_matrix[yt, yp] += w
  
          if it is not None:
              ids[yt, yp].append(it)
  
          if ip is not None:
              ids[yt, yp].append(ip)
  
      return confusion_matrix, ids
  
file_path: fiftyone/fiftyone/utils/eval/base.py
imports: import itertools
  import numpy
  import sklearn.metrics
  import fiftyone.core.evaluation
  import fiftyone.core.plots
label_desc: Use image node_id 4 for calling a global function with example usage: _compute_confusion_matrix(ytrue, ypred, labels, weights, ytrue_ids, ypred_ids, tabulate_ids) and returns: confusion_matrix,  ids, confusion_matrix,  ids