code: def test_infer_relative_search_space() -> None:
      def objective(trial: Trial) -> float:
          ret: float = trial.suggest_int("x1", 0, 10)
          ret += trial.suggest_int("x2", 1, 10, log=True)
          ret += trial.suggest_float("x3", 0, 10)
          ret += trial.suggest_float("x4", 1, 10, log=True)
          ret += trial.suggest_float("x5", 1, 10, step=3)
          _ = trial.suggest_categorical("x6", [1, 4, 7, 10])
          return ret
  
      sampler = _init_QMCSampler_without_exp_warning()
      study = optuna.create_study(sampler=sampler)
      trial = Mock()
      # In case no past trials.
      assert sampler.infer_relative_search_space(study, trial) == {}
      # In case there is a past trial.
      study.optimize(objective, n_trials=1)
      relative_search_space = sampler.infer_relative_search_space(
          study, trial
      )
      assert len(relative_search_space.keys()) == 5
      assert set(relative_search_space.keys()) == {
          "x1",
          "x2",
          "x3",
          "x4",
          "x5",
      }
      # In case self._initial_trial already exists.
      new_search_space: Dict[str, BaseDistribution] = {"x": Mock()}
      sampler._initial_search_space = new_search_space
      assert (
          sampler.infer_relative_search_space(study, trial)
          == new_search_space
      )
  
imports: from typing import Any
  from typing import Callable
  from typing import Dict
  from unittest.mock import Mock
  from unittest.mock import patch
  import warnings
  import numpy
  import pytest
  import optuna
  from optuna.distributions import BaseDistribution
  from optuna.trial import Trial
  from optuna.trial import TrialState
label_desc: Use image node_id 5 for calling a global function with example usage: test_infer_relative_search_space() and returns: ret