code: def test_multiclass_classification(objective):
      from sklearn.datasets import load_iris
      from sklearn.model_selection import KFold
  
      def check_pred(preds, labels, output_margin):
          if output_margin:
              err = sum(
                  1
                  for i in range(len(preds))
                  if preds[i].argmax() != labels[i]
              ) / float(len(preds))
          else:
              err = sum(
                  1 for i in range(len(preds)) if preds[i] != labels[i]
              ) / float(len(preds))
          assert err < 0.4
  
      X, y = load_iris(return_X_y=True)
      kf = KFold(n_splits=2, shuffle=True, random_state=rng)
      for train_index, test_index in kf.split(X, y):
          xgb_model = xgb.XGBClassifier(objective=objective).fit(
              X[train_index], y[train_index]
          )
          assert xgb_model.get_booster().num_boosted_rounds() == 100
          preds = xgb_model.predict(X[test_index])
          # test other params in XGBClassifier().fit
          preds2 = xgb_model.predict(
              X[test_index], output_margin=True, iteration_range=(0, 1)
          )
          preds3 = xgb_model.predict(
              X[test_index], output_margin=True, iteration_range=None
          )
          preds4 = xgb_model.predict(
              X[test_index], output_margin=False, iteration_range=(0, 1)
          )
          labels = y[test_index]
  
          check_pred(preds, labels, output_margin=False)
          check_pred(preds2, labels, output_margin=True)
          check_pred(preds3, labels, output_margin=True)
          check_pred(preds4, labels, output_margin=False)
  
      cls = xgb.XGBClassifier(n_estimators=4).fit(X, y)
      assert cls.n_classes_ == 3
      proba = cls.predict_proba(X)
      assert proba.shape[0] == X.shape[0]
      assert proba.shape[1] == cls.n_classes_
  
      # custom objective, the default is multi:softprob so no transformation is required.
      cls = xgb.XGBClassifier(
          n_estimators=4, objective=tm.softprob_obj(3)
      ).fit(X, y)
      proba = cls.predict_proba(X)
      assert proba.shape[0] == X.shape[0]
      assert proba.shape[1] == cls.n_classes_
  
imports: import json
  import os
  import pickle
  import random
  import tempfile
  import warnings
  from typing import Callable, Optional
  import numpy
  import pytest
  from sklearn.utils.estimator_checks import parametrize_with_checks
  import xgboost
  from xgboost import testing
  from xgboost.testing.ranking import run_ranking_categorical, run_ranking_qid_df
  from xgboost.testing.shared import get_feature_weights, validate_data_initialization
  from xgboost.testing.updater import get_basescore
label_desc: Use image node_id 2 for calling a global function with example usage: test_multiclass_classification(objective) without return types