code: def test_continue_when_trials_stopped(rosenbrock, facade):
      class CustomCallbackTrials(Callback):
          def on_tell_end(
              self, smbo, info: TrialInfo, value: TrialValue
          ) -> bool | None:
              if smbo.runhistory.finished == 20:
                  return False
  
              return
  
      # We did not optimize in the first run
      scenario = Scenario(
          rosenbrock.configspace,
          n_trials=25,
          min_budget=1,
          max_budget=10,
      )
      smac = facade(
          scenario,
          rosenbrock.train,
          callbacks=[CustomCallbackTrials()],
          overwrite=True,
      )
      smac.optimize()
  
      # Because of the callback, we stop after evaluating 20 trials
      assert smac.runhistory.finished == 20
  
      # Now we want to continue the run
      scenario = Scenario(
          rosenbrock.configspace,
          n_trials=25,
          min_budget=1,
          max_budget=10,
      )
      smac2 = facade(scenario, rosenbrock.train)
  
      # Let's see if we restored the runhistory correctly
      assert smac2.runhistory.finished == 20
  
      smac2.optimize()
      assert smac2.runhistory.finished == 25
  
file_path: SMAC3/tests/test_continue.py
imports: from __future__ import annotations
  import os
  import shutil
  from io import StringIO
  import pytest
  from smac import AlgorithmConfigurationFacade
  from smac import BlackBoxFacade
  from smac import HyperbandFacade
  from smac import HyperparameterOptimizationFacade
  from smac import MultiFidelityFacade
  from smac import RandomFacade
  from smac import Scenario
  from smac.callback.callback import Callback
  from smac.runhistory.dataclasses import TrialInfo, TrialValue
label_desc: Use image node_id 3 for calling a global function with example usage: test_continue_when_trials_stopped(rosenbrock, facade) and returns: False