code: def save_load_model(model_path: str) -> None:
      from sklearn.datasets import load_digits
      from sklearn.model_selection import KFold
  
      rng = np.random.RandomState(1994)
  
      digits = load_digits(n_class=2)
      y = digits["target"]
      X = digits["data"]
      kf = KFold(n_splits=2, shuffle=True, random_state=rng)
      for train_index, test_index in kf.split(X, y):
          xgb_model = xgb.XGBClassifier().fit(
              X[train_index], y[train_index]
          )
          xgb_model.save_model(model_path)
  
          xgb_model = xgb.XGBClassifier()
          xgb_model.load_model(model_path)
  
          assert isinstance(xgb_model.classes_, np.ndarray)
          np.testing.assert_equal(xgb_model.classes_, np.array([0, 1]))
          assert isinstance(xgb_model._Booster, xgb.Booster)
  
          preds = xgb_model.predict(X[test_index])
          labels = y[test_index]
          err = sum(
              1
              for i in range(len(preds))
              if int(preds[i] > 0.5) != labels[i]
          ) / float(len(preds))
          assert err < 0.1
          assert xgb_model.get_booster().attr("scikit_learn") is None
  
          # test native booster
          preds = xgb_model.predict(X[test_index], output_margin=True)
          booster = xgb.Booster(model_file=model_path)
          predt_1 = booster.predict(
              xgb.DMatrix(X[test_index]), output_margin=True
          )
          assert np.allclose(preds, predt_1)
  
          with pytest.raises(TypeError):
              xgb_model = xgb.XGBModel()
              xgb_model.load_model(model_path)
  
      clf = xgb.XGBClassifier(
          booster="gblinear", early_stopping_rounds=1
      )
      clf.fit(X, y, eval_set=[(X, y)])
      best_iteration = clf.best_iteration
      best_score = clf.best_score
      predt_0 = clf.predict(X)
      clf.save_model(model_path)
      clf.load_model(model_path)
      assert clf.booster == "gblinear"
      predt_1 = clf.predict(X)
      np.testing.assert_allclose(predt_0, predt_1)
      assert clf.best_iteration == best_iteration
      assert clf.best_score == best_score
  
      clfpkl = pickle.dumps(clf)
      clf = pickle.loads(clfpkl)
      predt_2 = clf.predict(X)
      np.testing.assert_allclose(predt_0, predt_2)
      assert clf.best_iteration == best_iteration
      assert clf.best_score == best_score
  
imports: import json
  import locale
  import os
  import pickle
  import tempfile
  from pathlib import Path
  from typing import List
  import numpy
  import pytest
  import xgboost
  from xgboost import testing
label_desc: Use image node_id 2 for calling a global function with example usage: save_load_model(model_path) without return types