class_docstr: Implements a hyperparameter optimization algorithm.
  
  In a parallel tuning setting, there is only one `Oracle` instance. The
  workers would communicate with the centralized `Oracle` instance with gPRC
  calls to the `Oracle` methods.
  
  `Trial` objects are often used as the communication packet through the gPRC
  calls to pass information between the worker `Tuner` instances and the
  `Oracle`. For example, `Oracle.create_trial()` returns a `Trial` object, and
  `Oracle.end_trial()` accepts a `Trial` in its arguments.
  
  New copies of the same `Trial` instance are reconstructed as it going
  through the gRPC calls. The changes to the `Trial` objects in the worker
  `Tuner`s are synced to the original copy in the `Oracle` when they are
  passed back to the `Oracle` by calling `Oracle.end_trial()`.
  
  Args:
      objective: A string, `keras_tuner.Objective` instance, or a list of
          `keras_tuner.Objective`s and strings. If a string, the direction of
          the optimization (min or max) will be inferred. If a list of
          `keras_tuner.Objective`, we will minimize the sum of all the
          objectives to minimize subtracting the sum of all the objectives to
          maximize. The `objective` argument is optional when
          `Tuner.run_trial()` or `HyperModel.fit()` returns a single float as
          the objective to minimize.
      max_trials: Integer, the total number of trials (model configurations)
          to test at most. Note that the oracle may interrupt the search
          before `max_trial` models have been tested if the search space has
          been exhausted.
      hyperparameters: Optional `HyperParameters` instance. Can be used to
          override (or register in advance) hyperparameters in the search
          space.
      tune_new_entries: Boolean, whether hyperparameter entries that are
          requested by the hypermodel but that were not specified in
          `hyperparameters` should be added to the search space, or not. If
          not, then the default value for these parameters will be used.
          Defaults to True.
      allow_new_entries: Boolean, whether the hypermodel is allowed to
          request hyperparameter entries not listed in `hyperparameters`.
          Defaults to True.
      seed: Int. Random seed.
      max_retries_per_trial: Integer. Defaults to 0. The maximum number of
          times to retry a `Trial` if the trial crashed or the results are
          invalid.
      max_consecutive_failed_trials: Integer. Defaults to 3. The maximum
          number of consecutive failed `Trial`s. When this number is reached,
          the search will be stopped. A `Trial` is marked as failed when none
          of the retries succeeded.
docstr: Create a new `Trial` to be run by the `Tuner`.
  
  A `Trial` corresponds to a unique set of hyperparameters to be run
  by `Tuner.run_trial`.
  
  Args:
      tuner_id: A string, the 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.
  
  Returns:
      A `Trial` object containing a set of hyperparameter values to run
      in a `Tuner`.
docstr_tok: ["Create","a","new","`","Trial","`","to","be","run","by","the","`","Tuner","`",".","A","`","Trial","`","corresponds","to","a","unique","set","of","hyperparameters","to","be","run","by","`","Tuner.run_trial","`",".","Args",":","tuner_id",":","A","string",",","the","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",".","Returns",":","A","`","Trial","`","object","containing","a","set","of","hyperparameter","values","to","run","in","a","`","Tuner","`","."]
code: def create_trial(self, tuner_id):
      """Create a new `Trial` to be run by the `Tuner`.
  
      A `Trial` corresponds to a unique set of hyperparameters to be run
      by `Tuner.run_trial`.
  
      Args:
          tuner_id: A string, the 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.
  
      Returns:
          A `Trial` object containing a set of hyperparameter values to run
          in a `Tuner`.
      """
      # Allow for multi-worker DistributionStrategy within a Trial.
      if tuner_id in self.ongoing_trials:
          return self.ongoing_trials[tuner_id]
  
      # Record all running client Tuner IDs.
      self.tuner_ids.add(tuner_id)
  
      # Pick the Trials waiting for retry first.
      if len(self._retry_queue) > 0:
          trial = self.trials[self._retry_queue.pop()]
          trial.status = trial_module.TrialStatus.RUNNING
          self.ongoing_trials[tuner_id] = trial
          self.save()
          self._display.on_trial_begin(trial)
          return trial
  
      # Make the trial_id the current number of trial, pre-padded with 0s
      trial_id = f"{{:0{len(str(self.max_trials))}d}}"
      trial_id = trial_id.format(len(self.trials))
  
      if self.max_trials and len(self.trials) >= self.max_trials:
          status = trial_module.TrialStatus.STOPPED
          values = None
      else:
          response = self.populate_space(trial_id)
          status = response["status"]
          values = response["values"] if "values" in response else None
  
      hyperparameters = self.hyperparameters.copy()
      hyperparameters.values = values or {}
  
      trial = trial_module.Trial(
          hyperparameters=hyperparameters,
          trial_id=trial_id,
          status=status,
      )
  
      if status == trial_module.TrialStatus.RUNNING:
          # Record the populated values (active only). Only record when the
          # status is RUNNING. If other status, the trial will not run, the
          # values are discarded and should not be recorded, in which case,
          # the trial_id may appear again in the future.
          self._record_values(trial)
  
          self.ongoing_trials[tuner_id] = trial
          self.trials[trial_id] = trial
          self.start_order.append(trial_id)
          self._save_trial(trial)
          self.save()
          self._display.on_trial_begin(trial)
  
      # Remove the client Tuner ID when triggered the client to exit
      if status == trial_module.TrialStatus.STOPPED:
          self.tuner_ids.remove(tuner_id)
  
      return trial
  
imports: import collections
  import hashlib
  import os
  import random
  import threading
  import warnings
  from datetime import datetime
  import numpy
  from keras_tuner import backend
  from keras_tuner import utils
  from keras_tuner.api_export import keras_tuner_export
  from keras_tuner.engine import hyperparameters
  from keras_tuner.engine import objective
  from keras_tuner.engine import stateful
  from keras_tuner.engine import trial
label_desc: Use image node_id 8 for calling the Oracle obj's underlying member method code with example usage: obj.create_trial(tuner_id) and returns: trial, self, trial