code: def test_catboost_pruning_callback_init_param(
      metric: str, eval_set_index: int
  ) -> None:
      def objective(trial: optuna.trial.Trial) -> float:
          train_x = np.asarray([[1.0], [2.0]])
          train_y = np.asarray([[1.0], [0.0]])
          valid_x = np.asarray([[1.0], [2.0]])
          valid_y = np.asarray([[1.0], [0.0]])
  
          if eval_set_index is None:
              eval_set = [(valid_x, valid_y)]
              pruning_callback = CatBoostPruningCallback(trial, metric)
          else:
              eval_set = [(valid_x, valid_y), (valid_x, valid_y)]
              pruning_callback = CatBoostPruningCallback(
                  trial, metric, eval_set_index
              )
  
          param = {
              "objective": "Logloss",
              "eval_metric": metric,
          }
  
          gbm = cb.CatBoostClassifier(**param)
          gbm.fit(
              train_x,
              train_y,
              eval_set=eval_set,
              verbose=0,
              callbacks=[pruning_callback],
          )
  
          # Invoke pruning manually.
          pruning_callback.check_pruned()
  
          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_catboost.py
imports: import types
  import numpy
  import pytest
  import optuna
  from optuna._imports import try_import
  from optuna.integration.catboost import CatBoostPruningCallback
  from optuna.testing.pruners import DeterministicPruner
label_desc: Use image node_id 2 for calling a global function with example usage: test_catboost_pruning_callback_init_param(metric, eval_set_index) and returns: int