code: def test_get_best_trials(tmp_path):
      def _test_get_best_trials():
          hps = keras_tuner.HyperParameters()
          hps.Int("a", 0, 100, default=5)
          hps.Int("b", 0, 100, default=6)
          oracle = randomsearch.RandomSearchOracle(
              objective=keras_tuner.Objective("score", direction="max"),
              max_trials=10,
              hyperparameters=hps,
          )
          oracle._set_project_dir(tmp_path, "untitled")
          tuner_id = os.environ["KERASTUNER_TUNER_ID"]
          if "chief" in tuner_id:
              oracle_chief.start_server(oracle)
          else:
              client = oracle_client.OracleClient(oracle)
              trial_scores = {}
              for score in range(10):
                  trial = client.create_trial(tuner_id)
                  assert trial.status == "RUNNING"
                  assert "a" in trial.hyperparameters.values
                  assert "b" in trial.hyperparameters.values
                  trial_id = trial.trial_id
                  client.update_trial(trial_id, {"score": score})
                  trial.status = "COMPLETED"
                  client.end_trial(trial)
                  trial_scores[trial_id] = score
              best_trials = client.get_best_trials(3)
              best_scores = [t.score for t in best_trials]
              assert best_scores == [9, 8, 7]
              # Check that trial_ids are correctly mapped to scores.
              for t in best_trials:
                  assert trial_scores[t.trial_id] == t.score
  
      mock_distribute.mock_distribute(
          _test_get_best_trials, num_workers=1
      )
  
file_path: keras-tuner/keras_tuner/distribute/oracle_chief_test.py
imports: import os
  import keras_tuner
  from keras_tuner.distribute import oracle_chief
  from keras_tuner.distribute import oracle_client
  from keras_tuner.engine import metrics_tracking
  from keras_tuner.test_utils import mock_distribute
  from keras_tuner.tuners import randomsearch
label_desc: Use image node_id 6 for calling a global function with example usage: test_get_best_trials(tmp_path) without return types