code: def test_base_tuner(tmp_path):
      class MyTuner(base_tuner.BaseTuner):
          def run_trial(self, trial, x):
              model = self.hypermodel.build(trial.hyperparameters)
              self.oracle.update_space(trial.hyperparameters)
              score = model(x)
              return {"score": score}
  
          def get_best_models(self, num_models=1):
              best_trials = self.oracle.get_best_trials(num_models)
              models = [
                  self.hypermodel.build(t.hyperparameters)
                  for t in best_trials
              ]
              return models
  
      def build_model(hp):
          class MyModel:
              def __init__(self):
                  self.factor = hp.Float("a", 0, 10)
  
              def __call__(self, x):
                  return self.factor * x
  
          return MyModel()
  
      oracle = randomsearch.RandomSearchOracle(
          objective=keras_tuner.Objective("score", "max"), max_trials=5
      )
      tuner = MyTuner(
          oracle=oracle, hypermodel=build_model, directory=tmp_path
      )
      tuner.search(1.0)
      models = tuner.get_best_models(5)
  
      # Check that scoring of the model was done correctly.
      models_by_factor = sorted(
          models, key=lambda m: m.factor, reverse=True
      )
      assert models[0] == models_by_factor[0]
  
imports: import os
  import pickle
  import time
  import numpy
  import pytest
  from sklearn import linear_model
  import keras_tuner
  from keras_tuner import errors
  from keras_tuner.distribute import oracle_client
  from keras_tuner.engine import base_tuner
  from keras_tuner.test_utils import mock_distribute
  from keras_tuner.tuners import gridsearch
  from keras_tuner.tuners import randomsearch
label_desc: Use image node_id 1 for calling a global function with example usage: test_base_tuner(tmp_path) and returns: MyModel, dict, models, unknown