code: def test_hp_in_fit(tmp_path):
      class MyHyperModel(hypermodel.HyperModel):
          def build(self, hp):
              hp.Fixed("fixed", 3)
              return keras.Sequential()
  
          def fit(self, hp, model, *args, **kwargs):
              hp.Choice("choice", [0, 1, 2])
              return random.random()
  
      tuner = gridsearch.GridSearch(
          hypermodel=MyHyperModel(), directory=tmp_path
      )
      tuner.search(verbose=0)
      assert len(tuner.oracle.trials) == 3
  
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 4 for calling a global function with example usage: test_hp_in_fit(tmp_path) and returns: keras, random