code: def run_adaptive(self, tree_method, weighted) -> None:
      rng = np.random.RandomState(1994)
      from sklearn.datasets import make_regression
      from sklearn.utils import stats
  
      n_samples = 256
      X, y = make_regression(n_samples, 16, random_state=rng)
      if weighted:
          w = rng.normal(size=n_samples)
          w -= w.min()
          Xy = xgb.DMatrix(X, y, weight=w)
          base_score = stats._weighted_percentile(y, w, percentile=50)
      else:
          Xy = xgb.DMatrix(X, y)
          base_score = np.median(y)
  
      booster_0 = xgb.train(
          {
              "tree_method": tree_method,
              "base_score": base_score,
              "objective": "reg:absoluteerror",
          },
          Xy,
          num_boost_round=1,
      )
      booster_1 = xgb.train(
          {
              "tree_method": tree_method,
              "objective": "reg:absoluteerror",
          },
          Xy,
          num_boost_round=1,
      )
      config_0 = json.loads(booster_0.save_config())
      config_1 = json.loads(booster_1.save_config())
  
      def get_score(config: Dict) -> float:
          return float(
              config["learner"]["learner_model_param"]["base_score"]
          )
  
      assert get_score(config_0) == get_score(config_1)
  
      with pytest.warns(
          Warning, match="Model format is default to UBJSON"
      ):
          raw_booster = booster_1.save_raw(raw_format="deprecated")
      booster_2 = xgb.Booster(model_file=raw_booster)
      config_2 = json.loads(booster_2.save_config())
      assert get_score(config_1) == get_score(config_2)
  
      raw_booster = booster_1.save_raw(raw_format="ubj")
      booster_2 = xgb.Booster(model_file=raw_booster)
      config_2 = json.loads(booster_2.save_config())
      assert get_score(config_1) == get_score(config_2)
  
      booster_0 = xgb.train(
          {
              "tree_method": tree_method,
              "base_score": base_score + 1.0,
              "objective": "reg:absoluteerror",
          },
          Xy,
          num_boost_round=1,
      )
      config_0 = json.loads(booster_0.save_config())
      np.testing.assert_allclose(
          get_score(config_0), get_score(config_1) + 1
      )
  
      evals_result: Dict[str, Dict[str, list]] = {}
      xgb.train(
          {
              "tree_method": tree_method,
              "objective": "reg:absoluteerror",
              "subsample": 0.8,
              "eta": 1.0,
          },
          Xy,
          num_boost_round=10,
          evals=[(Xy, "Train")],
          evals_result=evals_result,
      )
      mae = evals_result["Train"]["mae"]
      assert mae[-1] < 20.0
      assert tm.non_increasing(mae)
  
imports: import json
  from string import ascii_lowercase
  from typing import Any, Dict
  import numpy
  import pytest
  from hypothesis import given, note, settings, strategies
  import xgboost
  from xgboost import testing
  from xgboost.testing.params import cat_parameter_strategy, exact_parameter_strategy, hist_cache_strategy, hist_parameter_strategy
  from xgboost.testing.updater import check_categorical_missing, check_categorical_ohe, check_get_quantile_cut, check_init_estimation, check_quantile_loss, train_result
label_desc: Use image node_id 16 for calling the TestTreeMethod obj's underlying member method code with example usage: obj.run_adaptive(tree_method, weighted) and returns: float