code: def test_xgboost_pruning_callback() -> None:
      def objective(trial: optuna.trial.Trial) -> float:
          dtrain = xgb.DMatrix(np.asarray([[1.0]]), label=[1.0])
          dtest = xgb.DMatrix(np.asarray([[1.0]]), label=[1.0])
  
          pruning_callback = XGBoostPruningCallback(
              trial, "validation-logloss"
          )
          xgb.train(
              {"objective": "binary:logistic"},
              dtrain,
              1,
              evals=[(dtest, "validation")],
              verbose_eval=False,
              callbacks=[pruning_callback],
          )
          return 1.0
  
      study = optuna.create_study(pruner=DeterministicPruner(True))
      study.optimize(objective, n_trials=1)
      assert study.trials[0].state == optuna.trial.TrialState.PRUNED
  
      study = optuna.create_study(pruner=DeterministicPruner(False))
      study.optimize(objective, n_trials=1)
      assert study.trials[0].state == optuna.trial.TrialState.COMPLETE
      assert study.trials[0].value == 1.0
  
file_path: optuna/tests/integration_tests/test_xgboost.py
imports: import numpy
  import pytest
  import optuna
  from optuna._imports import try_import
  from optuna.integration.xgboost import XGBoostPruningCallback
  from optuna.testing.pruners import DeterministicPruner
label_desc: Use image node_id 2 for calling a global function with example usage: test_xgboost_pruning_callback() and returns: int