code: def test_terminator_callback_terminator() -> None:
      # This test case validates that the study is stopped when the `should_terminate` method of the
      # terminator returns `True` for the first time.
      termination_trial_number = 10
  
      callback = TerminatorCallback(
          terminator=_DeterministicTerminator(termination_trial_number),
      )
  
      study = create_study()
      study.optimize(lambda _: 0.0, callbacks=[callback], n_trials=100)
  
      assert len(study.trials) == termination_trial_number + 1
  
file_path: optuna/tests/terminator_tests/test_callback.py
imports: from optuna.study import create_study
  from optuna.study import Study
  from optuna.terminator import BaseTerminator
  from optuna.terminator import TerminatorCallback
  from optuna.trial import TrialState
label_desc: Use image node_id 1 for calling a global function with example usage: test_terminator_callback_terminator() without return types