code: def _sklearn_auroc_multilabel(
      preds, target, average="macro", ignore_index=None
  ):
      if ignore_index is None:
          if preds.ndim > 2:
              target = target.transpose(2, 1).reshape(-1, NUM_CLASSES)
              preds = preds.transpose(2, 1).reshape(-1, NUM_CLASSES)
          target = target.numpy()
          preds = preds.numpy()
          if not ((preds > 0) & (preds < 1)).all():
              preds = sigmoid(preds)
          return sk_roc_auc_score(
              target, preds, average=average, max_fpr=None
          )
      if average == "micro":
          return _sklearn_auroc_binary(
              preds.flatten(),
              target.flatten(),
              max_fpr=None,
              ignore_index=ignore_index,
          )
      res = [
          _sklearn_auroc_binary(
              preds[:, i],
              target[:, i],
              max_fpr=None,
              ignore_index=ignore_index,
          )
          for i in range(NUM_CLASSES)
      ]
      if average == "macro":
          return np.array(res)[~np.isnan(res)].mean()
      if average == "weighted":
          weights = (
              (target == 1).sum([0, 2])
              if target.ndim == 3
              else (target == 1).sum(0)
          ).numpy()
          weights = weights / sum(weights)
          return (np.array(res) * weights)[~np.isnan(res)].sum()
      return res
  
imports: from functools import partial
  import numpy
  import pytest
  import torch
  from scipy.special import expit
  from scipy.special import softmax
  from sklearn.metrics import roc_auc_score
  from torchmetrics.classification.auroc import AUROC, BinaryAUROC, MulticlassAUROC, MultilabelAUROC
  from torchmetrics.functional.classification.auroc import binary_auroc, multiclass_auroc, multilabel_auroc
  from torchmetrics.functional.classification.roc import binary_roc
  from torchmetrics.metric import Metric
  from unittests import NUM_CLASSES
  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 3 for calling a global function with example usage: _sklearn_auroc_multilabel(preds, target, average, ignore_index) and returns: res, sk_roc_auc_score, _sklearn_auroc_binary, np, unknown