code: def test_precision_recall_f1_score_multiclass(setup):
      # Test Precision Recall and F1 Score for multiclass classification task
      y_true, y_pred, _ = make_prediction(binary=False)
      y_true = mt.tensor(y_true, chunk_size=40)
      y_pred = mt.tensor(y_pred, chunk_size=40)
  
      # compute scores with default labels introspection
      p, r, f, s = fetch(
          execute(
              precision_recall_fscore_support(
                  y_true, y_pred, average=None
              )
          )
      )
      assert_array_almost_equal(p, [0.83, 0.33, 0.42], 2)
      assert_array_almost_equal(r, [0.79, 0.09, 0.90], 2)
      assert_array_almost_equal(f, [0.81, 0.15, 0.57], 2)
      assert_array_equal(s, [24, 31, 20])
  
      # averaging tests
      ps = fetch(
          execute(
              precision_score(
                  y_true, y_pred, pos_label=1, average="micro"
              )
          )
      )
      assert_array_almost_equal(ps, 0.53, 2)
  
      rs = fetch(execute(recall_score(y_true, y_pred, average="micro")))
      assert_array_almost_equal(rs, 0.53, 2)
  
      fs = fetch(execute(f1_score(y_true, y_pred, average="micro")))
      assert_array_almost_equal(fs, 0.53, 2)
  
      ps = fetch(
          execute(precision_score(y_true, y_pred, average="macro"))
      )
      assert_array_almost_equal(ps, 0.53, 2)
  
      rs = fetch(execute(recall_score(y_true, y_pred, average="macro")))
      assert_array_almost_equal(rs, 0.60, 2)
  
      fs = fetch(execute(f1_score(y_true, y_pred, average="macro")))
      assert_array_almost_equal(fs, 0.51, 2)
  
      ps = fetch(
          execute(precision_score(y_true, y_pred, average="weighted"))
      )
      assert_array_almost_equal(ps, 0.51, 2)
  
      rs = fetch(
          execute(recall_score(y_true, y_pred, average="weighted"))
      )
      assert_array_almost_equal(rs, 0.53, 2)
  
      fs = fetch(execute(f1_score(y_true, y_pred, average="weighted")))
      assert_array_almost_equal(fs, 0.47, 2)
  
      with pytest.raises(ValueError):
          precision_score(y_true, y_pred, average="samples")
      with pytest.raises(ValueError):
          recall_score(y_true, y_pred, average="samples")
      with pytest.raises(ValueError):
          f1_score(y_true, y_pred, average="samples")
      with pytest.raises(ValueError):
          fbeta_score(y_true, y_pred, average="samples", beta=0.5)
  
      # same prediction but with and explicit label ordering
      p, r, f, s = fetch(
          execute(
              precision_recall_fscore_support(
                  y_true, y_pred, labels=[0, 2, 1], average=None
              )
          )
      )
      assert_array_almost_equal(p, [0.83, 0.41, 0.33], 2)
      assert_array_almost_equal(r, [0.79, 0.90, 0.10], 2)
      assert_array_almost_equal(f, [0.81, 0.57, 0.15], 2)
      assert_array_equal(s, [24, 20, 31])
  
imports: import numpy
  import pytest
  from sklearn import datasets, svm
  from sklearn.exceptions import UndefinedMetricWarning
  from sklearn.metrics import accuracy_score
  from sklearn.utils import check_random_state
  from sklearn.utils._testing import assert_almost_equal, assert_array_equal, assert_array_almost_equal
  from sklearn.utils._mocking import MockDataFrame
  from ....None import execute, fetch
  from ....None import tensor
  from ....lib.sparse import SparseNDArray
  from ..None import accuracy_score, log_loss
  from .._classification import _check_targets, multilabel_confusion_matrix, precision_recall_fscore_support, precision_score, recall_score, f1_score, fbeta_score
label_desc: Use image node_id 11 for calling a global function with example usage: test_precision_recall_f1_score_multiclass(setup) without return types