code: def sample_relative(self, study, trial, search_space):
      if search_space == {}:
          return {}
  
      # Simulated Annealing algorithm.
      # 1. Calculate transition probability.
      prev_trial = study.trials[-2]
      if (
          self._current_trial is None
          or prev_trial.value <= self._current_trial.value
      ):
          probability = 1.0
      else:
          probability = np.exp(
              (self._current_trial.value - prev_trial.value)
              / self._temperature
          )
      self._temperature *= 0.9  # Decrease temperature.
  
      # 2. Transit the current state if the previous result is accepted.
      if self._rng.uniform(0, 1) < probability:
          self._current_trial = prev_trial
  
      # 3. Sample parameters from the neighborhood of the current point.
      # The sampled parameters will be used during the next execution of
      # the objective function passed to the study.
      params = {}
      for param_name, param_distribution in search_space.items():
          if (
              not isinstance(
                  param_distribution,
                  optuna.distributions.FloatDistribution,
              )
              or (
                  param_distribution.step is not None
                  and param_distribution.step != 1
              )
              or param_distribution.log
          ):
              msg = (
                  "Only suggest_float() with `step` `None` or 1.0 and"
                  " `log` `False` is supported"
              )
              raise NotImplementedError(msg)
  
          current_value = self._current_trial.params[param_name]
          width = (
              param_distribution.high - param_distribution.low
          ) * 0.1
          neighbor_low = max(
              current_value - width, param_distribution.low
          )
          neighbor_high = min(
              current_value + width, param_distribution.high
          )
          params[param_name] = self._rng.uniform(
              neighbor_low, neighbor_high
          )
  
      return params
  
file_path: optuna/tutorial/20_recipes/005_user_defined_sampler.py
imports: import numpy
  import optuna
label_desc: Use image node_id 2 for calling the SimulatedAnnealingSampler obj's underlying member method code with example usage: obj.sample_relative(study, trial, search_space) and returns: params, dict