code: def test_hyperband_load_weights(tmp_path):
      tuner = hyperband_module.Hyperband(
          objective="val_loss",
          hypermodel=build_model,
          hyperband_iterations=1,
          max_epochs=2,
          factor=2,
          directory=tmp_path,
      )
      x, y = np.ones((2, INPUT_DIM)), np.ones((2, 1))
      nb_brackets = tuner.oracle._get_num_brackets()
      assert nb_brackets == 2
      nb_models_round_0 = tuner.oracle._get_size(
          bracket_num=1, round_num=0
      )
      assert nb_models_round_0 == 2
      # run the trials for the round 0 (from scratch)
      for _ in range(nb_models_round_0):
          trial = tuner.oracle.create_trial("tuner0")
          result = tuner.run_trial(trial, x, y, validation_data=(x, y))
          tuner.oracle.update_trial(
              trial.trial_id,
              tuner_utils.convert_to_metrics_dict(
                  result, tuner.oracle.objective
              ),
              tuner_utils.get_best_step(result, tuner.oracle.objective),
          )
          trial.status = "COMPLETED"
          tuner.oracle.end_trial(trial)
  
      # ensure the model run in round 1 is loaded from the best model in round 0
      trial = tuner.oracle.create_trial("tuner0")
      hp = trial.hyperparameters
      assert "tuner/trial_id" in hp
      new_model = tuner._try_build(hp)
      assert new_model.predict(x).shape == y.shape
      # get new model weights
      new_model_weights = new_model.weights.copy()
      # get weights from the best model in round 0
      best_trial_round_0_id = hp["tuner/trial_id"]
      best_hp_round_0 = tuner.oracle.trials[
          best_trial_round_0_id
      ].hyperparameters
      best_model_round_0 = tuner._try_build(best_hp_round_0)
      if backend.config.multi_backend():
          best_model_round_0.build_from_config(
              utils.load_json(
                  tuner._get_build_config_fname(best_trial_round_0_id)
              )
          )
      best_model_round_0.load_weights(
          tuner._get_checkpoint_fname(best_trial_round_0_id)
      )
      assert best_model_round_0.predict(x).shape == y.shape
      best_model_round_0_weights = best_model_round_0.weights.copy()
      # compare the weights
      assert len(new_model_weights) == len(best_model_round_0_weights)
      assert all(
          np.all(np.array(new_weight) == np.array(best_old_weight))
          for new_weight, best_old_weight in zip(
              new_model_weights, best_model_round_0_weights
          )
      )
  
file_path: keras-tuner/keras_tuner/tuners/hyperband_test.py
imports: import numpy
  import pytest
  import keras_tuner
  from keras_tuner import backend
  from keras_tuner import utils
  from keras_tuner.backend import keras
  from keras_tuner.engine import tuner_utils
  from keras_tuner.tuners import hyperband
label_desc: Use image node_id 7 for calling a global function with example usage: test_hyperband_load_weights(tmp_path) without return types