code: def test_study_optimize_with_infinite_search_space() -> None:
      def objective(trial: Trial) -> float:
          return trial.suggest_float("a", 0, 2)
  
      study = optuna.create_study(sampler=samplers.BruteForceSampler())
  
      with pytest.raises(ValueError):
          study.optimize(objective)
  
file_path: optuna/tests/samplers_tests/test_brute_force.py
imports: import numpy
  import pytest
  import optuna
  from optuna import samplers
  from optuna.samplers._brute_force import _TreeNode
  from optuna.trial import Trial
label_desc: Use image node_id 6 for calling a global function with example usage: test_study_optimize_with_infinite_search_space() and returns: trial