code: def test_do_switching(make_scenario):
      seed = 42
      configspace = _test_helpers.get_branin_config_space()
      scenario = make_scenario(
          configspace=configspace,
      )
      config = scenario.configspace.sample_configuration()
      rh = RunHistory()
      rh.add(config, 10, 10, StatusType.SUCCESS)
      tae = lambda x: x
      turbo_kwargs = {"failure_tol_min": 1, "length_min": 0.6}
  
      facade = BOinGFacade(
          scenario=scenario,
          runhistory=rh,
          target_function=tae,
          do_switching=True,
          turbo_kwargs=turbo_kwargs,
          overwrite=True,
      )
      optimizer = facade.optimizer
  
      for i in range(15):
          config = scenario.configspace.sample_configuration()
          rh.add(config, 10, 10, StatusType.SUCCESS)
      config = scenario.configspace.sample_configuration()
      # ensure config is the incumbent
      rh.add(config, 9.99, 10, StatusType.SUCCESS)
      next(optimizer.ask())
  
      # init an optimal config
      np.testing.assert_allclose(
          config.get_array(), optimizer.optimal_config
      )
      assert optimizer.optimal_value == 9.99
      assert 0 == optimizer.failcount_BOinG
  
      optimizer.failcount_BOinG = 19
      # in this case, prob_to_TurBO becomes 1
      with patch("smac.main.boing.BOinGSMBO." "restart_TuRBOinG") as mk:
          next(optimizer.ask())
          assert optimizer.run_TuRBO is True
          assert mk.called is True
  
      # switch to TuRBO
      from smac.utils.subspaces.turbo_subspace import TuRBOSubSpace
  
      for i in range(1000):
          with patch.object(
              smac.utils.subspaces.turbo_subspace.TuRBOSubSpace,
              "generate_challengers",
              return_value=None,
          ):
              optimizer.ask()
              while len(optimizer.turbo_optimizer.init_configs) > 0:
                  optimizer.turbo_optimizer.init_configs.pop()
          if not optimizer.run_TuRBO:
              break
      # TuRBO will be replaced with BOinG if it cannot find a better value continuously
      assert i < 999
  
      optimizer.failcount_BOinG = 19
      next(optimizer.ask())
  
      config = scenario.configspace.sample_configuration()
      rh.add(config, 9.5, 10, StatusType.SUCCESS)
      optimizer.turbo_optimizer.init_configs = []
      for i in range(10):
          next(optimizer.ask())
          if not optimizer.run_TuRBO:
              break
      # one time success and two times failure totally, 3 times evaluations and in this case we have i==2
      assert i == 2
  
file_path: SMAC3/tests/test_main/_test_boing.py
imports: from unittest.mock import patch
  import numpy
  import pytest
  from ConfigSpace import CategoricalHyperparameter, ConfigurationSpace, UniformFloatHyperparameter
  import smac
  from smac.facade.blackbox_facade import BlackBoxFacade
  from smac.facade.hyperparameter_optimization_facade import HyperparameterOptimizationFacade
  from smac.facade.old.boing_facade import BOinGFacade
  from smac.main.boing import subspace_extraction
  from smac.model.random_forest.random_forest import RandomForest
  from smac.model.utils import check_subspace_points, get_types
  from smac.runhistory.runhistory import RunHistory
  from smac.runner.abstract_runner import StatusType
  from smac.utils import _test_helpers
label_desc: Use image node_id 3 for calling a global function with example usage: test_do_switching(make_scenario) without return types