code: def test_thresholded_multilabel_multioutput_permutations_invariance(
      name,
  ):
      random_state = check_random_state(0)
      n_samples, n_classes = 20, 4
      y_true = random_state.randint(0, 2, size=(n_samples, n_classes))
      y_score = random_state.normal(size=y_true.shape)
  
      # Makes sure all samples have at least one label. This works around errors
      # when running metrics where average="sample"
      y_true[y_true.sum(1) == 4, 0] = 0
      y_true[y_true.sum(1) == 0, 0] = 1
  
      metric = ALL_METRICS[name]
      score = metric(y_true, y_score)
  
      for perm in permutations(range(n_classes), n_classes):
          y_score_perm = y_score[:, perm]
          y_true_perm = y_true[:, perm]
  
          current_score = metric(y_true_perm, y_score_perm)
          if metric == mean_absolute_percentage_error:
              assert np.isfinite(current_score)
              assert current_score > 1e6
              # Here we are not comparing the values in case of MAPE because
              # whenever y_true value is exactly zero, the MAPE value doesn't
              # signify anything. Thus, in this case we are just expecting
              # very large finite value.
          else:
              assert_almost_equal(score, current_score)
  
imports: from functools import partial
  from inspect import signature
  from itertools import chain, permutations, product
  import numpy
  import pytest
  from sklearn._config import config_context
  from sklearn.datasets import make_multilabel_classification
  from sklearn.metrics import accuracy_score, average_precision_score, balanced_accuracy_score, brier_score_loss, cohen_kappa_score, confusion_matrix, coverage_error, d2_absolute_error_score, d2_pinball_score, d2_tweedie_score, dcg_score, det_curve, explained_variance_score, f1_score, fbeta_score, hamming_loss, hinge_loss, jaccard_score, label_ranking_average_precision_score, label_ranking_loss, log_loss, matthews_corrcoef, max_error, mean_absolute_error, mean_absolute_percentage_error, mean_gamma_deviance, mean_pinball_loss, mean_poisson_deviance, mean_squared_error, mean_tweedie_deviance, median_absolute_error, multilabel_confusion_matrix, ndcg_score, precision_recall_curve, precision_score, r2_score, recall_score, roc_auc_score, roc_curve, top_k_accuracy_score, zero_one_loss
  from sklearn.metrics._base import _average_binary_score
  from sklearn.preprocessing import LabelBinarizer
  from sklearn.utils import shuffle
  from sklearn.utils._array_api import _atol_for_type, yield_namespace_device_dtype_combinations
  from sklearn.utils._testing import _array_api_for_tests, assert_allclose, assert_almost_equal, assert_array_equal, assert_array_less, ignore_warnings
  from sklearn.utils.fixes import COO_CONTAINERS
  from sklearn.utils.multiclass import type_of_target
  from sklearn.utils.validation import _num_samples, check_random_state
label_desc: Use image node_id 39 for calling a global function with example usage: test_thresholded_multilabel_multioutput_permutations_invariance(name) without return types