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: KerasTuner Oracle interface implemented with Vizier backend.
  
  This is an implementation of kerasTuner Oracle that uses Google Cloud's
  Vizier Service. CloudTuner uses this Oracle.
  
  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 KerasTuner Oracles please refer to:
  https://keras-team.github.io/keras-tuner/documentation/oracles/
  
  Examples:
  
  ```
  oracle = CloudOracle(
      project_id=project_id,
      region='us-central1',
      objective='accuracy',
      hyperparameters=hyperparameters,
      study_config=None,
      max_trials=4,
      study_id=None,
  )
  ```
  
  Args:
      project_id: A GCP project id.
      region: A GCP region. e.g. 'us-central1'.
      objective: If a string, the direction of the optimization (min or
          max) will be inferred.
      hyperparameters: Mandatory and must include definitions for all
          hyperparameters used during the search. Can be used to override
          (or register in advance) hyperparameters in the search space.
      study_config: Study configuration for Vizier service.
      max_trials: Total number of trials (model configurations) to test at
          most. If None, it continues the search until it reaches the
          Vizier trial limit for each study. Users may stop the search
          externally (e.g. by killing the job). Note that the Oracle may
          interrupt the search before `max_trials` models have been
          tested.
      study_id: An identifier of the study. If not supplied,
          system-determined unique ID is given.
          The full study name will be
          `projects/{project_id}/locations/{region}/studies/{study_id}`,
          and the full trial name will be
          `{study name}/trials/{trial_id}`.
docstr_tok: ["KerasTuner","Oracle","interface","implemented","with","Vizier","backend",".","This","is","an","implementation","of","kerasTuner","Oracle","that","uses","Google","Cloud's","Vizier","Service",".","CloudTuner","uses","this","Oracle",".","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","KerasTuner","Oracles","please","refer","to",":","https",":","\/\/keras-team.github.io\/keras-tuner\/documentation\/oracles\/","Examples",":","``","`","oracle","=","CloudOracle","(","project_id=project_id",",","region='us-central1","'",",","objective='accuracy","'",",","hyperparameters=hyperparameters",",","study_config=None",",","max_trials=4",",","study_id=None",",",")","``","`","Args",":","project_id",":","A","GCP","project","id",".","region",":","A","GCP","region",".","e.g",".","'us-central1","'",".","objective",":","If","a","string",",","the","direction","of","the","optimization","(","min","or","max",")","will","be","inferred",".","hyperparameters",":","Mandatory","and","must","include","definitions","for","all","hyperparameters","used","during","the","search",".","Can","be","used","to","override","(","or","register","in","advance",")","hyperparameters","in","the","search","space",".","study_config",":","Study","configuration","for","Vizier","service",".","max_trials",":","Total","number","of","trials","(","model","configurations",")","to","test","at","most",".","If","None",",","it","continues","the","search","until","it","reaches","the","Vizier","trial","limit","for","each","study",".","Users","may","stop","the","search","externally","(","e.g",".","by","killing","the","job",")",".","Note","that","the","Oracle","may","interrupt","the","search","before","`","max_trials","`","models","have","been","tested",".","study_id",":","An","identifier","of","the","study",".","If","not","supplied",",","system-determined","unique","ID","is","given",".","The","full","study","name","will","be","`","projects\/","{","project_id","}","\/locations\/","{","region","}","\/studies\/","{","study_id","}","`",",","and","the","full","trial","name","will","be","`","{","study","name","}","\/trials\/","{","trial_id","}","`","."]
code: def __init__(
      self,
      project_id: Text,
      region: Text,
      objective: Optional[Union[Text, oracle_module.Objective]] = None,
      hyperparameters: Optional[hp_module.HyperParameters] = None,
      study_config: Optional[Dict[Text, Any]] = None,
      max_trials: Optional[int] = None,
      study_id: Optional[Text] = None,
  ):
      """KerasTuner Oracle interface implemented with Vizier backend.
  
      This is an implementation of kerasTuner Oracle that uses Google Cloud's
      Vizier Service. CloudTuner uses this Oracle.
  
      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 KerasTuner Oracles please refer to:
      https://keras-team.github.io/keras-tuner/documentation/oracles/
  
      Examples:
  
      ```
      oracle = CloudOracle(
          project_id=project_id,
          region='us-central1',
          objective='accuracy',
          hyperparameters=hyperparameters,
          study_config=None,
          max_trials=4,
          study_id=None,
      )
      ```
  
      Args:
          project_id: A GCP project id.
          region: A GCP region. e.g. 'us-central1'.
          objective: If a string, the direction of the optimization (min or
              max) will be inferred.
          hyperparameters: Mandatory and must include definitions for all
              hyperparameters used during the search. Can be used to override
              (or register in advance) hyperparameters in the search space.
          study_config: Study configuration for Vizier service.
          max_trials: Total number of trials (model configurations) to test at
              most. If None, it continues the search until it reaches the
              Vizier trial limit for each study. Users may stop the search
              externally (e.g. by killing the job). Note that the Oracle may
              interrupt the search before `max_trials` models have been
              tested.
          study_id: An identifier of the study. If not supplied,
              system-determined unique ID is given.
              The full study name will be
              `projects/{project_id}/locations/{region}/studies/{study_id}`,
              and the full trial name will be
              `{study name}/trials/{trial_id}`.
      """
      if study_config:
          if objective or hyperparameters:
              raise ValueError(
                  "Please configure either study_config or "
                  '"objective, and hyperparameters".'
              )
          objective = utils.convert_study_config_to_objective(
              study_config
          )
          hyperparameters = utils.convert_study_config_to_hps(
              study_config
          )
          self.study_config = study_config
      else:
          if not (objective and hyperparameters):
              raise ValueError(
                  "If study_config is not set, "
                  "objective and hyperparameters must be set."
              )
          self.study_config = utils.make_study_config(
              objective, hyperparameters
          )
  
      super(CloudOracle, self).__init__(
          objective=objective,
          hyperparameters=hyperparameters,
          max_trials=max_trials,
          allow_new_entries=False,
          tune_new_entries=False,
      )
  
      if not project_id:
          raise ValueError('"project_id" is not found.')
      self._project_id = project_id
  
      if not region:
          raise ValueError('"region" is not found.')
      self._region = region
  
      # If it's just single objective, let it be an Objective instead of a
      # list, to keep it consistent with how KerasTuner formats objectives
      obj = utils.format_objective(objective)
      self.objective = obj[0] if len(obj) == 1 else obj
  
      self.hyperparameters = hyperparameters
      self.max_trials = max_trials
  
      self.study_id = study_id or "CloudTuner_study_{}".format(
          datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
      )
  
      self.service = vizier_client.create_or_load_study(
          self._project_id,
          self._region,
          self.study_id,
          self.study_config,
      )
  
      self.trials = {}
      self._start_time = None
  
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 1 to create a new CloudOracle object from inherited base classes: oracle_module with example: obj = CloudOracle(project_id, region, objective, hyperparameters, study_config, max_trials, study_id)