code: def test_that_exhaustive_space_is_explored(tmp_path):
      # Tests that it explores the whole search space given by the combination
      # of all hyperparameter of Choice type.
  
      # Given
      want_units_1 = [2, 4]
      want_units_2 = [1, 3]
      want_optimizers = ["adam", "sgd", "rmsprop"]
      want_loss = "binary_crossentropy"
      want_dropouts = [True, False]
  
      class MyGridSearch(gridsearch.GridSearch):
          def run_trial(self, trial, *args, **kwargs):
              hp = trial.hyperparameters
              hp.Choice("units_1", values=want_units_1)
              hp.Boolean("dropout", default=want_dropouts[0])
              hp.Choice("units_2", values=want_units_2)
              hp.Choice("optmizer", values=want_optimizers),
              hp.Fixed("loss", value=want_loss)
              return random.random()
  
      # When
      tuner = MyGridSearch(directory=tmp_path)
      tuner.search()
  
      # Then
      assert {hp.name for hp in tuner.oracle.get_space().space} == {
          "units_1",
          "optmizer",
          "units_2",
          "loss",
          "dropout",
      }
  
      # 2 units_1, 3 optimizers, 2 units_2, 2 dropout and 1 loss
      expected_hyperparameter_space = 24
      assert len(tuner.oracle.trials) == expected_hyperparameter_space
  
      trials = tuner.oracle.get_best_trials(
          num_trials=expected_hyperparameter_space
      )
      explored_space = [
          trial.hyperparameters.values for trial in trials
      ]
      for want_unit_1 in want_units_1:
          for want_unit_2 in want_units_2:
              for want_optimizer in want_optimizers:
                  for want_dropout in want_dropouts:
                      assert {
                          "units_1": want_unit_1,
                          "units_2": want_unit_2,
                          "optmizer": want_optimizer,
                          "loss": want_loss,
                          "dropout": want_dropout,
                      } in explored_space
  
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 1 for calling a global function with example usage: test_that_exhaustive_space_is_explored(tmp_path) and returns: random