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: Create a new `Trial` to be run by the `Tuner`.
  
  Args:
      tuner_id: An ID that identifies the `Tuner` requesting a `Trial`.
          `Tuners` that should run the same trial (for instance, when
          running a multi-worker model) should have the same ID. If
          multiple suggestTrialsRequests have the same tuner_id, the
          service will return the identical suggested trial if the trial
          is PENDING, and provide a new trial if the last suggested trial
          was completed.
  
  Returns:
      A `Trial` object containing a set of hyperparameter values to run
      in a `Tuner`.
  
  Raises:
      SuggestionInactiveError: Indicates that a suggestion was requested
          from an inactive study.
docstr_tok: ["Create","a","new","`","Trial","`","to","be","run","by","the","`","Tuner","`",".","Args",":","tuner_id",":","An","ID","that","identifies","the","`","Tuner","`","requesting","a","`","Trial","`",".","`","Tuners","`","that","should","run","the","same","trial","(","for","instance",",","when","running","a","multi-worker","model",")","should","have","the","same","ID",".","If","multiple","suggestTrialsRequests","have","the","same","tuner_id",",","the","service","will","return","the","identical","suggested","trial","if","the","trial","is","PENDING",",","and","provide","a","new","trial","if","the","last","suggested","trial","was","completed",".","Returns",":","A","`","Trial","`","object","containing","a","set","of","hyperparameter","values","to","run","in","a","`","Tuner","`",".","Raises",":","SuggestionInactiveError",":","Indicates","that","a","suggestion","was","requested","from","an","inactive","study","."]
code: def create_trial(self, tuner_id: Text) -> trial_module.Trial:
      """Create a new `Trial` to be run by the `Tuner`.
  
      Args:
          tuner_id: An ID that identifies the `Tuner` requesting a `Trial`.
              `Tuners` that should run the same trial (for instance, when
              running a multi-worker model) should have the same ID. If
              multiple suggestTrialsRequests have the same tuner_id, the
              service will return the identical suggested trial if the trial
              is PENDING, and provide a new trial if the last suggested trial
              was completed.
  
      Returns:
          A `Trial` object containing a set of hyperparameter values to run
          in a `Tuner`.
  
      Raises:
          SuggestionInactiveError: Indicates that a suggestion was requested
              from an inactive study.
      """
      # List all trials from the same study and see if any
      # trial.status=STOPPED or if number of trials >= max_limit.
      trial_list = self.service.list_trials()
      # Note that KerasTunerTrialStatus - 'STOPPED' is equivalent to
      # VizierTrialState - 'STOPPING'.
      stopping_trials = [
          t for t in trial_list if t["state"] == "STOPPING"
      ]
      if (
          self.max_trials and len(trial_list) >= self.max_trials
      ) or stopping_trials:
          trial_id = "n"
          hyperparameters = self.hyperparameters.copy()
          hyperparameters.values = {}
          # This will break the search loop later.
          return trial_module.Trial(
              hyperparameters=hyperparameters,
              trial_id=trial_id,
              status=trial_module.TrialStatus.STOPPED,
          )
  
      # Get suggestions
      suggestions = self.service.get_suggestions(tuner_id)
  
      if not suggestions:
          return trial_module.Trial(
              hyperparameters={},
              status=trial_module.TrialStatus.STOPPED,
          )
  
      # Fetches the suggested trial.
      # Vizier Trial instance
      vizier_trial = suggestions[0]
      trial_id = utils.get_trial_id(vizier_trial)
  
      # KerasTuner Trial instance
      keras_tuner_trial = trial_module.Trial(
          hyperparameters=utils.convert_vizier_trial_to_hps(
              self.hyperparameters.copy(), vizier_trial
          ),
          trial_id=trial_id,
          status=trial_module.TrialStatus.RUNNING,
      )
  
      tf.get_logger().info(
          "Hyperparameters requested by tuner ({}): {} ".format(
              tuner_id, keras_tuner_trial.hyperparameters.values
          )
      )
  
      self._start_time = time.time()
      self.trials[trial_id] = keras_tuner_trial
      self.ongoing_trials[tuner_id] = keras_tuner_trial
      self._save_trial(keras_tuner_trial)
      self.save()
      return keras_tuner_trial
  
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 2 for calling the CloudOracle obj's underlying member method code with example usage: obj.create_trial(tuner_id) and returns: keras_tuner_trial, trial_module, trial_module