code: def test_conditional_scope(tmp_path):
      class MyHyperModel(hypermodel.HyperModel):
          def build(self, hp):
              a = hp.Boolean("bool")
              with hp.conditional_scope("bool", [True]):
                  if a:
                      hp.Choice("choice1", [1, 2])
              with hp.conditional_scope("bool", [False]):
                  if not a:
                      hp.Choice("choice2", [3, 4])
              return keras.Sequential()
  
          def fit(self, hp, model, *args, **kwargs):
              a = hp.Boolean("bool2")
              with hp.conditional_scope("bool2", [True]):
                  if a:
                      hp.Choice("choice3", [1, 2])
              with hp.conditional_scope("bool2", [False]):
                  if not a:
                      hp.Choice("choice4", [3, 4])
              return random.random()
  
      tuner = gridsearch.GridSearch(
          hypermodel=MyHyperModel(), directory=tmp_path
      )
      tuner.search(verbose=0)
      assert len(tuner.oracle.trials) == 4 * 4
  
file_path: keras-tuner/keras_tuner/tuners/gridsearch_test.py
imports: import random
  from keras_tuner.backend import keras
  from keras_tuner.engine import hypermodel
  from keras_tuner.engine import trial
  from keras_tuner.tuners import gridsearch
label_desc: Use image node_id 5 for calling a global function with example usage: test_conditional_scope(tmp_path) and returns: keras, random