code: def test_hyperopt(parametrization, has_transform) -> None:
      optim1 = registry["HyperOpt"](
          parametrization=parametrization, budget=5
      )
      optim2 = registry["HyperOpt"](
          parametrization=parametrization.copy(), budget=5
      )
      for it in range(4):
          cand = optim1.ask()
          optim1.tell(cand, 0)  # Tell asked
          del cand._meta["trial_id"]
          optim2.tell(cand, 0)  # Tell not asked
          assert flatten(optim1.trials._dynamic_trials[it]["misc"]["vals"]) == pytest.approx(  # type: ignore
              flatten(optim2.trials._dynamic_trials[it]["misc"]["vals"])  # type: ignore
          )
  
      assert optim1.trials.new_trial_ids(1) == optim2.trials.new_trial_ids(1)  # type: ignore
      assert optim1.trials.new_trial_ids(1)[0] == (it + 2)  # type: ignore
      assert (optim1._transform is not None) == has_transform  # type: ignore
  
      # Test parallelization
      opt = registry["HyperOpt"](
          parametrization=parametrization, budget=30, num_workers=5
      )
      for k in range(40):
          cand = opt.ask()
          if not k:
              opt.tell(cand, 1)
  
file_path: nevergrad/nevergrad/optimization/test_externalbo.py
imports: import pytest
  import numpy
  import nevergrad
  from nevergrad.common.tools import flatten
  from .optimizerlib import registry
  from .externalbo import _hp_parametrization_to_dict, _hp_dict_to_parametrization
label_desc: Use image node_id 1 for calling a global function with example usage: test_hyperopt(parametrization, has_transform) without return types