code: def test_classification_multiclass():
      """
      Expects
      -------
      * Correct scores from CLASSIFICATION_METRICS for multiclass classification.
      """
      # The last check in this test has a mismatch between the number of
      # labels predicted in y_pred and the number of labels in y_true.
      # This triggers several warnings but we are aware.
      #
      # TODO convert to pytest with fixture
      #
      #   This test should be parameterized so we can identify which metrics
      #   cause which warning specifically and rectify if needed.
      ignored_warnings = [
          (UserWarning, "y_pred contains classes not in y_true")
      ]
  
      for (
          metric,
          scorer,
      ) in autosklearn.metrics.CLASSIFICATION_METRICS.items():
          # Skip functions not applicable for multiclass classification.
          if metric in [
              "roc_auc",
              "average_precision",
              "precision",
              "recall",
              "f1",
              "precision_samples",
              "recall_samples",
              "f1_samples",
          ]:
              continue
  
          y_true = np.array([0.0, 0.0, 1.0, 1.0, 2.0])
  
          y_pred_list = [
              np.array(
                  [
                      [1.0, 0.0, 0.0],
                      [1.0, 0.0, 0.0],
                      [0.0, 1.0, 0.0],
                      [0.0, 1.0, 0.0],
                      [0.0, 0.0, 1.0],
                  ]
              ),
              np.array(
                  [
                      [1.0, 0.0, 0.0],
                      [1.0, 0.0, 0.0],
                      [1.0, 0.0, 0.0],
                      [0.0, 1.0, 0.0],
                      [0.0, 0.0, 1.0],
                  ]
              ),
              np.array(
                  [
                      [0.0, 0.0, 1.0],
                      [0.0, 1.0, 0.0],
                      [1.0, 0.0, 0.0],
                      [0.0, 1.0, 0.0],
                      [0.0, 1.0, 0.0],
                  ]
              ),
              np.array(
                  [
                      [0.0, 0.0, 1.0],
                      [0.0, 0.0, 1.0],
                      [1.0, 0.0, 0.0],
                      [1.0, 0.0, 0.0],
                      [0.0, 1.0, 0.0],
                  ]
              ),
          ]
  
          score_list = [
              scorer(y_true, y_pred) for y_pred in y_pred_list
          ]
  
          assert scorer._optimum == pytest.approx(score_list[0])
          assert score_list == sorted(score_list, reverse=True)
  
          # less labels in the targets than in the predictions
          y_true = np.array([0.0, 0.0, 1.0, 1.0])
          y_pred = np.array(
              [
                  [1.0, 0.0, 0.0],
                  [1.0, 0.0, 0.0],
                  [0.0, 1.0, 0.0],
                  [0.0, 0.0, 1.0],
              ]
          )
  
          with warnings.catch_warnings():
              for category, message in ignored_warnings:
                  warnings.filterwarnings(
                      "ignore", category=category, message=message
                  )
  
              score = scorer(y_true, y_pred)
              assert np.isfinite(score)
  
imports: import warnings
  import numpy
  import sklearn.metrics
  import autosklearn.metrics
  from autosklearn.constants import BINARY_CLASSIFICATION, REGRESSION
  from autosklearn.metrics import calculate_losses, calculate_scores, compute_single_metric
  import pytest
  import unittest
label_desc: Use image node_id 7 for calling a global function with example usage: test_classification_multiclass() without return types