code: def test_sample_relative_prior() -> None:
      study = optuna.create_study()
      dist = optuna.distributions.FloatDistribution(1.0, 100.0)
      past_trials = [
          frozen_trial_factory(i, dist=dist) for i in range(1, 8)
      ]
  
      # Prepare a trial and a sample for later checks.
      trial = frozen_trial_factory(8)
      with warnings.catch_warnings():
          warnings.simplefilter(
              "ignore", optuna.exceptions.ExperimentalWarning
          )
          sampler = TPESampler(
              n_startup_trials=5, seed=0, multivariate=True
          )
      with patch.object(
          study._storage, "get_all_trials", return_value=past_trials
      ):
          suggestion = sampler.sample_relative(
              study, trial, {"param-a": dist}
          )
  
      with warnings.catch_warnings():
          warnings.simplefilter(
              "ignore", optuna.exceptions.ExperimentalWarning
          )
          sampler = TPESampler(
              consider_prior=False,
              n_startup_trials=5,
              seed=0,
              multivariate=True,
          )
      with patch.object(
          study._storage, "get_all_trials", return_value=past_trials
      ):
          assert (
              sampler.sample_relative(study, trial, {"param-a": dist})
              != suggestion
          )
  
      with warnings.catch_warnings():
          warnings.simplefilter(
              "ignore", optuna.exceptions.ExperimentalWarning
          )
          sampler = TPESampler(
              prior_weight=0.2,
              n_startup_trials=5,
              seed=0,
              multivariate=True,
          )
      with patch.object(
          study._storage, "get_all_trials", return_value=past_trials
      ):
          assert (
              sampler.sample_relative(study, trial, {"param-a": dist})
              != suggestion
          )
  
imports: from __future__ import annotations
  import random
  from typing import Callable
  from typing import Dict
  from typing import Optional
  from typing import Union
  from unittest.mock import Mock
  from unittest.mock import patch
  import warnings
  import _pytest.capture
  import numpy
  import pytest
  import optuna
  from optuna import distributions
  from optuna.samplers import _tpe
  from optuna.samplers import TPESampler
  from optuna.samplers._base import _CONSTRAINTS_KEY
  from optuna.trial import Trial
label_desc: Use image node_id 8 for calling a global function with example usage: test_sample_relative_prior() without return types