code: def test_group_decomposed_search_space() -> None:
      search_space = _GroupDecomposedSearchSpace()
      study = create_study()
  
      # No trial.
      assert search_space.calculate(study).search_spaces == []
  
      # A single parameter.
      study.optimize(lambda t: t.suggest_int("x", 0, 10), n_trials=1)
      assert search_space.calculate(study).search_spaces == [
          {"x": IntDistribution(low=0, high=10)}
      ]
  
      # Disjoint parameters.
      study.optimize(
          lambda t: t.suggest_int("y", 0, 10)
          + t.suggest_float("z", -3, 3),
          n_trials=1,
      )
      assert search_space.calculate(study).search_spaces == [
          {"x": IntDistribution(low=0, high=10)},
          {
              "y": IntDistribution(low=0, high=10),
              "z": FloatDistribution(low=-3, high=3),
          },
      ]
  
      # Parameters which include one of search spaces in the group.
      study.optimize(
          lambda t: t.suggest_int("y", 0, 10)
          + t.suggest_float("z", -3, 3)
          + t.suggest_float("u", 1e-2, 1e2, log=True)
          + bool(t.suggest_categorical("v", ["A", "B", "C"])),
          n_trials=1,
      )
      assert search_space.calculate(study).search_spaces == [
          {"x": IntDistribution(low=0, high=10)},
          {
              "z": FloatDistribution(low=-3, high=3),
              "y": IntDistribution(low=0, high=10),
          },
          {
              "u": FloatDistribution(low=1e-2, high=1e2, log=True),
              "v": CategoricalDistribution(choices=["A", "B", "C"]),
          },
      ]
  
      # A parameter which is included by one of search spaces in thew group.
      study.optimize(
          lambda t: t.suggest_float("u", 1e-2, 1e2, log=True),
          n_trials=1,
      )
      assert search_space.calculate(study).search_spaces == [
          {"x": IntDistribution(low=0, high=10)},
          {
              "y": IntDistribution(low=0, high=10),
              "z": FloatDistribution(low=-3, high=3),
          },
          {"u": FloatDistribution(low=1e-2, high=1e2, log=True)},
          {"v": CategoricalDistribution(choices=["A", "B", "C"])},
      ]
  
      # Parameters whose intersection with one of search spaces in the group is not empty.
      study.optimize(
          lambda t: t.suggest_int("y", 0, 10)
          + t.suggest_int("w", 2, 8, log=True),
          n_trials=1,
      )
      assert search_space.calculate(study).search_spaces == [
          {"x": IntDistribution(low=0, high=10)},
          {"y": IntDistribution(low=0, high=10)},
          {"z": FloatDistribution(low=-3, high=3)},
          {"u": FloatDistribution(low=1e-2, high=1e2, log=True)},
          {"v": CategoricalDistribution(choices=["A", "B", "C"])},
          {"w": IntDistribution(low=2, high=8, log=True)},
      ]
  
      search_space = _GroupDecomposedSearchSpace()
      study = create_study()
  
      # Failed or pruned trials are not considered in the calculation of
      # an intersection search space.
      def objective(trial: Trial, exception: Exception) -> float:
          trial.suggest_float("a", 0, 1)
          raise exception
  
      study.optimize(
          lambda t: objective(t, RuntimeError()),
          n_trials=1,
          catch=(RuntimeError,),
      )
      study.optimize(lambda t: objective(t, TrialPruned()), n_trials=1)
      assert search_space.calculate(study).search_spaces == []
  
      # If two parameters have the same name but different distributions,
      # the first one takes priority.
      study.optimize(lambda t: t.suggest_float("a", -1, 1), n_trials=1)
      study.optimize(lambda t: t.suggest_float("a", 0, 1), n_trials=1)
      assert search_space.calculate(study).search_spaces == [
          {"a": FloatDistribution(low=-1, high=1)}
      ]
  
file_path: optuna/tests/search_space_tests/test_group_decomposed.py
imports: import pytest
  from optuna import create_study
  from optuna import TrialPruned
  from optuna.distributions import CategoricalDistribution
  from optuna.distributions import FloatDistribution
  from optuna.distributions import IntDistribution
  from optuna.search_space import _GroupDecomposedSearchSpace
  from optuna.search_space import _SearchSpaceGroup
  from optuna.testing.storages import StorageSupplier
  from optuna.trial import Trial
label_desc: Use image node_id 2 for calling a global function with example usage: test_group_decomposed_search_space() without return types