code: def _sklearn_ranking(preds, target, fn, ignore_index):
      preds = preds.numpy()
      target = target.numpy()
      if (
          np.issubdtype(preds.dtype, np.floating)
          and not ((preds > 0) & (preds < 1)).all()
      ):
          preds = sigmoid(preds)
      preds = np.moveaxis(preds, 1, -1).reshape((-1, preds.shape[1]))
      target = np.moveaxis(target, 1, -1).reshape((-1, target.shape[1]))
      if ignore_index is not None:
          idx = target == ignore_index
          target[idx] = -1
      return fn(target, preds)
  
imports: from functools import partial
  import numpy
  import pytest
  import torch
  from scipy.special import expit
  from sklearn.metrics import coverage_error
  from sklearn.metrics import label_ranking_average_precision_score
  from sklearn.metrics import label_ranking_loss
  from torchmetrics.classification.ranking import MultilabelCoverageError, MultilabelRankingAveragePrecision, MultilabelRankingLoss
  from torchmetrics.functional.classification.ranking import multilabel_coverage_error, multilabel_ranking_average_precision, multilabel_ranking_loss
  from unittests import NUM_CLASSES
  from unittests.classification.inputs import _multilabel_cases
  from unittests.helpers import seed_all
  from unittests.helpers.testers import MetricTester, inject_ignore_index
label_desc: Use image node_id 1 for calling a global function with example usage: _sklearn_ranking(preds, target, fn, ignore_index) and returns: fn