code: def _confusion_matrix(
      labels,
      predictions,
      num_classes=None,
      weights=None,
      dtype=np.int32,
      name=None,
  ):
      """Return confusion matrix between predictions and labels."""
      del name
      if num_classes is None:
          num_classes = (
              np.maximum(np.max(predictions), np.max(labels)) + 1
          )
      cmatrix = np.zeros(
          [num_classes, num_classes], dtype=utils.numpy_dtype(dtype)
      )
      if weights is None:
          weights = 1
      if not JAX_MODE:
          np.add.at(cmatrix, (labels, predictions), weights)
          return cmatrix
      return cmatrix.at[(labels, predictions)].add(weights)
  
imports: import collections
  import functools
  import numpy
  import numpy
  from tensorflow_probability.python.internal.backend.numpy import _utils
  from tensorflow_probability.python.internal.backend.numpy.numpy_array import _reverse
  from tensorflow_probability.python.internal.backend.numpy.numpy_array import one_hot
  from tensorflow_probability.python.internal.backend.numpy.ops import _convert_to_tensor
label_desc: Use image node_id 4 for calling a global function with example usage: _confusion_matrix(labels, predictions, num_classes, weights, dtype, name) and returns: cmatrix, cmatrix