code: def test_update_space(tmp_path):
      # Tests that HyperParameters added after the first call to `build_model`
      # are sent to the Oracle via oracle.update_space.
      def build_model(hp):
          model = keras.Sequential()
          for i in range(hp.Int("layers", 0, 2)):
              model.add(
                  keras.layers.Dense(
                      units=hp.Int(f"units_{str(i)}", 2, 4, 2),
                      activation="relu",
                  )
              )
  
          model.add(keras.layers.Dense(1, activation="sigmoid"))
          model.compile(
              "adam", loss="binary_crossentropy", metrics=["accuracy"]
          )
          return model
  
      class MyRandomSearch(randomsearch.RandomSearchOracle):
          def populate_space(self, trial_id):
              result = super().populate_space(trial_id)
              if "values" in result:
                  result["values"]["layers"] = 2
              return result
  
      tuner = tuner_module.Tuner(
          oracle=MyRandomSearch(objective="accuracy", max_trials=1),
          hypermodel=build_model,
          directory=tmp_path,
      )
  
      assert {hp.name for hp in tuner.oracle.get_space().space} == {
          "layers"
      }
  
      x, y = np.ones((10, 10)), np.ones((10, 1))
      tuner.search(x, y, epochs=1)
  
      assert {hp.name for hp in tuner.oracle.get_space().space} == {
          "layers",
          "units_0",
          "units_1",
      }
  
imports: import numpy
  from keras_tuner.backend import keras
  from keras_tuner.engine import tuner
  from keras_tuner.tuners import randomsearch
label_desc: Use image node_id 1 for calling a global function with example usage: test_update_space(tmp_path) and returns: model, result