code: def _sklearn_fbeta_score_multilabel_local(
      preds, target, sk_fn, ignore_index, average
  ):
      fbeta_score, weights = [], []
      for i in range(preds.shape[0]):
          if average == "micro":
              pred, true = preds[i].flatten(), target[i].flatten()
              true, pred = remove_ignore_index(true, pred, ignore_index)
              fbeta_score.append(sk_fn(true, pred))
              confmat = sk_confusion_matrix(true, pred, labels=[0, 1])
              weights.append(confmat[1, 1] + confmat[1, 0])
          else:
              scores, w = [], []
              for j in range(preds.shape[1]):
                  pred, true = preds[i, j], target[i, j]
                  true, pred = remove_ignore_index(
                      true, pred, ignore_index
                  )
                  scores.append(sk_fn(true, pred))
                  confmat = sk_confusion_matrix(
                      true, pred, labels=[0, 1]
                  )
                  w.append(confmat[1, 1] + confmat[1, 0])
              fbeta_score.append(np.stack(scores))
              weights.append(np.stack(w))
      if average == "micro":
          return np.array(fbeta_score)
      res = np.stack(fbeta_score, 0)
      if average == "macro":
          return res.mean(-1)
      if average == "weighted":
          weights = np.stack(weights, 0).astype(float)
          weights_norm = weights.sum(-1, keepdims=True)
          weights_norm[weights_norm == 0] = 1.0
          return ((weights * res) / weights_norm).sum(-1)
      if average is None or average == "none":
          return res
      return None
  
imports: from functools import partial
  import numpy
  import pytest
  import torch
  from scipy.special import expit
  from sklearn.metrics import confusion_matrix
  from sklearn.metrics import f1_score
  from sklearn.metrics import fbeta_score
  from torch import Tensor
  from torchmetrics.classification.f_beta import BinaryF1Score, BinaryFBetaScore, F1Score, FBetaScore, MulticlassF1Score, MulticlassFBetaScore, MultilabelF1Score, MultilabelFBetaScore
  from torchmetrics.functional.classification.f_beta import binary_f1_score, binary_fbeta_score, multiclass_f1_score, multiclass_fbeta_score, multilabel_f1_score, multilabel_fbeta_score
  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 5 for calling a global function with example usage: _sklearn_fbeta_score_multilabel_local(preds, target, sk_fn, ignore_index, average) and returns: None, np, res, unknown, res