code: def _local_cm(inputs, labels, use_sample_weight):
      if use_sample_weight:
          y_true, y_pred, sample_weight = inputs
      else:
          y_true, y_pred = inputs
          sample_weight = cp.ones(y_true.shape[0], dtype=y_true.dtype)
  
      y_true, _ = make_monotonic(y_true, labels, copy=True)
      y_pred, _ = make_monotonic(y_pred, labels, copy=True)
  
      n_labels = labels.size
  
      # intersect y_pred, y_true with labels, eliminate items not in labels
      ind = cp.logical_and(y_pred < n_labels, y_true < n_labels)
      y_pred = y_pred[ind]
      y_true = y_true[ind]
      sample_weight = sample_weight[ind]
      cm = cupyx.scipy.sparse.coo_matrix(
          (sample_weight, (y_true, y_pred)),
          shape=(n_labels, n_labels),
          dtype=cp.float64,
      ).toarray()
      return cp.nan_to_num(cm)
  
file_path: cuml/python/cuml/dask/metrics/confusion_matrix.py
imports: from cuml.prims.label import make_monotonic
  from cuml.dask.metrics.utils import sorted_unique_labels
  from cuml.internals.memory_utils import with_cupy_rmm
  from cuml.dask.common.utils import get_client
  from cuml.dask.common.input_utils import DistributedDataHandler
  from cuml.internals.safe_imports import gpu_only_import
  from cuml.internals.safe_imports import cpu_only_import
label_desc: Use image node_id 1 for calling a global function with example usage: _local_cm(inputs, labels, use_sample_weight) and returns: cp