code: def _sklearn_confusion_matrix_multilabel(
      preds, target, normalize=None, ignore_index=None
  ):
      preds = preds.numpy()
      target = target.numpy()
      if np.issubdtype(preds.dtype, np.floating):
          if not ((preds > 0) & (preds < 1)).all():
              preds = sigmoid(preds)
          preds = (preds >= THRESHOLD).astype(np.uint8)
      preds = np.moveaxis(preds, 1, -1).reshape((-1, preds.shape[1]))
      target = np.moveaxis(target, 1, -1).reshape((-1, target.shape[1]))
      confmat = []
      for i in range(preds.shape[1]):
          pred, true = preds[:, i], target[:, i]
          true, pred = remove_ignore_index(true, pred, ignore_index)
          confmat.append(
              sk_confusion_matrix(
                  true, pred, normalize=normalize, labels=[0, 1]
              )
          )
      return np.stack(confmat, axis=0)
  
imports: from functools import partial
  import numpy
  import pytest
  import torch
  from scipy.special import expit
  from sklearn.metrics import confusion_matrix
  from torchmetrics.classification.confusion_matrix import BinaryConfusionMatrix, ConfusionMatrix, MulticlassConfusionMatrix, MultilabelConfusionMatrix
  from torchmetrics.functional.classification.confusion_matrix import binary_confusion_matrix, multiclass_confusion_matrix, multilabel_confusion_matrix
  from torchmetrics.metric import Metric
  from unittests import NUM_CLASSES, THRESHOLD
  from unittests.classification.inputs import _binary_cases, _multiclass_cases, _multilabel_cases
  from unittests.helpers import seed_all
  from unittests.helpers.testers import MetricTester, inject_ignore_index, remove_ignore_index
label_desc: Use image node_id 4 for calling a global function with example usage: _sklearn_confusion_matrix_multilabel(preds, target, normalize, ignore_index) and returns: np