class_docstr: Keras Tuner Oracle that wraps the AI Platform Vizier backend.
  
  This is an implementation of `KerasTuner` Oracle that uses Google Cloud's
  Vizier Service.
  
  Each Oracle class implements a particular hyperparameter tuning algorithm.
  An Oracle is passed as an argument to a Tuner. The Oracle tells the Tuner
  which hyperparameters should be tried next.
  
  To learn more about Keras Tuner Oracles please refer to:
  https://keras-team.github.io/keras-tuner/documentation/oracles/
  
  AI Platform Vizier is a black-box optimization service that helps you tune
  hyperparameters in complex machine learning (ML) models. When ML models have
  many different hyperparameters, it can be difficult and time consuming to
  tune them manually. AI Platform Vizier optimizes your model's output by
  tuning the hyperparameters for you.
  To learn more about AI Platform Vizier service see:
      https://cloud.google.com/ai-platform/optimizer/docs/overview.
  
  Examples:
  
  ```
  oracle = CloudOracle(
      project_id=project_id,
      region='us-central1',
      objective='accuracy',
      hyperparameters=hyperparameters,
      study_config=None,
      max_trials=4,
      study_id=None,
  )
  ```
class_docstr_tok: ["Keras","Tuner","Oracle","that","wraps","the","AI","Platform","Vizier","backend",".","This","is","an","implementation","of","`","KerasTuner","`","Oracle","that","uses","Google","Cloud's","Vizier","Service",".","Each","Oracle","class","implements","a","particular","hyperparameter","tuning","algorithm",".","An","Oracle","is","passed","as","an","argument","to","a","Tuner",".","The","Oracle","tells","the","Tuner","which","hyperparameters","should","be","tried","next",".","To","learn","more","about","Keras","Tuner","Oracles","please","refer","to",":","https",":","\/\/keras-team.github.io\/keras-tuner\/documentation\/oracles\/","AI","Platform","Vizier","is","a","black-box","optimization","service","that","helps","you","tune","hyperparameters","in","complex","machine","learning","(","ML",")","models",".","When","ML","models","have","many","different","hyperparameters",",","it","can","be","difficult","and","time","consuming","to","tune","them","manually",".","AI","Platform","Vizier","optimizes","your","model","'s","output","by","tuning","the","hyperparameters","for","you",".","To","learn","more","about","AI","Platform","Vizier","service","see",":","https",":","\/\/cloud.google.com\/ai-platform\/optimizer\/docs\/overview",".","Examples",":","``","`","oracle","=","CloudOracle","(","project_id=project_id",",","region='us-central1","'",",","objective='accuracy","'",",","hyperparameters=hyperparameters",",","study_config=None",",","max_trials=4",",","study_id=None",",",")","``","`"]
docstr: Returns the trials with the best objective values found so far.
  
  Args:
      num_trials: positive int, number of trials to return.
  Returns:
      List of KerasTuner Trials.
docstr_tok: ["Returns","the","trials","with","the","best","objective","values","found","so","far",".","Args",":","num_trials",":","positive","int",",","number","of","trials","to","return",".","Returns",":","List","of","KerasTuner","Trials","."]
code: def get_best_trials(
      self, num_trials: int = 1
  ) -> List[trial_module.Trial]:
      """Returns the trials with the best objective values found so far.
  
      Args:
          num_trials: positive int, number of trials to return.
      Returns:
          List of KerasTuner Trials.
      """
      objective = self._get_objective()
      if len(objective) > 1:
          raise ValueError(
              "Getting the best trials for multi-objective optimization "
              "is not supported."
          )
  
      maximizing = (
          utils.format_goal(objective[0].direction) == "MAXIMIZE"
      )
  
      # List all trials associated with the same study
      trial_list = self.service.list_trials()
  
      vizier_trials = [
          t for t in trial_list if t["state"] == "COMPLETED"
      ]
  
      if not vizier_trials:
          return []
  
      sorted_trials = sorted(
          vizier_trials,
          key=lambda t: t["finalMeasurement"]["metrics"][0].get(
              "value"
          ),
          reverse=maximizing,
      )
      best_vizier_trials = sorted_trials[:num_trials]
  
      best_trials = []
      # Convert completed Vizier trials to KerasTuner Trial instances.
      for vizier_trial in best_vizier_trials:
          keras_tuner_trial = (
              utils.convert_completed_vizier_trial_to_keras_trial(
                  vizier_trial, self.hyperparameters.copy()
              )
          )
          best_trials.append(keras_tuner_trial)
      return best_trials
  
imports: import collections
  import copy
  import datetime
  import os
  import time
  from typing import Any, Callable, Dict, List, Mapping, Optional, Text, Union
  from keras_tuner.engine import hypermodel
  from keras_tuner.engine import hyperparameters
  from keras_tuner.engine import metrics_tracking
  from keras_tuner.engine import oracle
  from keras_tuner.engine import trial
  from keras_tuner.engine import tuner
  import tensorflow
  from tensorboard.plugins.hparams import api
  from tensorflow_cloud.core import deploy
  from tensorflow_cloud.core import machine_config
  from tensorflow_cloud.core import validate
  from tensorflow_cloud.tuner import cloud_fit_client
  from tensorflow_cloud.tuner import utils
  from tensorflow_cloud.tuner import vizier_client
  from tensorflow_cloud.utils import google_api_client
  from tensorflow_cloud.utils import tf_utils
label_desc: Use image node_id 5 for calling the CloudOracle obj's underlying member method code with example usage: obj.get_best_trials(num_trials) and returns: best_trials, list