code: def test_early_stopping_customize(self):
      D_train = xgb.DMatrix(self.X_train, self.y_train)
      D_valid = xgb.DMatrix(self.X_valid, self.y_valid)
      early_stopping_rounds = 5
      early_stop = xgb.callback.EarlyStopping(
          rounds=early_stopping_rounds,
          metric_name="CustomErr",
          data_name="Train",
      )
      # Specify which dataset and which metric should be used for early stopping.
      booster = xgb.train(
          {
              "objective": "binary:logistic",
              "eval_metric": ["error", "rmse"],
              "tree_method": "hist",
          },
          D_train,
          evals=[(D_train, "Train"), (D_valid, "Valid")],
          feval=tm.eval_error_metric,
          num_boost_round=1000,
          callbacks=[early_stop],
          verbose_eval=False,
      )
      dump = booster.get_dump(dump_format="json")
      assert (
          len(dump) - booster.best_iteration
          == early_stopping_rounds + 1
      )
      assert len(
          early_stop.stopping_history["Train"]["CustomErr"]
      ) == len(dump)
  
      rounds = 100
      early_stop = xgb.callback.EarlyStopping(
          rounds=early_stopping_rounds,
          metric_name="CustomErr",
          data_name="Train",
          min_delta=100,
          save_best=True,
      )
      booster = xgb.train(
          {
              "objective": "binary:logistic",
              "eval_metric": ["error", "rmse"],
              "tree_method": "hist",
          },
          D_train,
          evals=[(D_train, "Train"), (D_valid, "Valid")],
          feval=tm.eval_error_metric,
          num_boost_round=rounds,
          callbacks=[early_stop],
          verbose_eval=False,
      )
      # No iteration can be made with min_delta == 100
      assert booster.best_iteration == 0
      assert booster.num_boosted_rounds() == 1
  
imports: import json
  import os
  import tempfile
  from typing import Union
  import pytest
  import xgboost
  from xgboost import testing
label_desc: Use image node_id 6 for calling the TestCallbacks obj's underlying member method code with example usage: obj.test_early_stopping_customize() without return types