class_docstr: Tuner base class.
  
  `BaseTuner` is the super class of all `Tuner` classes. It defines the APIs
  for the `Tuner` classes and serves as a wrapper class for the internal
  logics.
  
  `BaseTuner` supports parallel tuning. In parallel tuning, the communication
  between `BaseTuner` and `Oracle` are all going through gRPC. There are
  multiple running instances of `BaseTuner` but only one `Oracle`. This design
  allows the user to run the same script on multiple machines to launch the
  parallel tuning.
  
  The `Oracle` instance should manage the life cycles of all the `Trial`s,
  while a `BaseTuner` is a worker for running the `Trial`s. `BaseTuner`s
  requests `Trial`s from the `Oracle`, run them, and report the results back
  to the `Oracle`. A `BaseTuner` also handles events happening during running
  the `Trial`, like saving the model, logging, error handling. Other than
  these responsibilities, a `BaseTuner` should avoid managing a `Trial` since
  the relevant contexts for a `Trial` are in the `Oracle`, which only
  accessible from gRPC.
  
  The `BaseTuner` should be a general tuner for all types of models and avoid
  any logic directly related to Keras. The Keras related logics should be
  handled by the `Tuner` class, which is a subclass of `BaseTuner`.
  
  Args:
      oracle: Instance of Oracle class.
      hypermodel: Instance of `HyperModel` class (or callable that takes
          hyperparameters and returns a `Model` instance). It is optional
          when `Tuner.run_trial()` is overriden and does not use
          `self.hypermodel`.
      directory: A string, the relative path to the working directory.
      project_name: A string, the name to use as prefix for files saved by
          this Tuner.
      overwrite: Boolean, defaults to `False`. If `False`, reloads an
          existing project of the same name if one is found. Otherwise,
          overwrites the project.
      **kwargs: Arguments for backward compatibility.
  
  Attributes:
      remaining_trials: Number of trials remaining, `None` if `max_trials` is
          not set. This is useful when resuming a previously stopped search.
class_docstr_tok: ["Tuner","base","class",".","`","BaseTuner","`","is","the","super","class","of","all","`","Tuner","`","classes",".","It","defines","the","APIs","for","the","`","Tuner","`","classes","and","serves","as","a","wrapper","class","for","the","internal","logics",".","`","BaseTuner","`","supports","parallel","tuning",".","In","parallel","tuning",",","the","communication","between","`","BaseTuner","`","and","`","Oracle","`","are","all","going","through","gRPC",".","There","are","multiple","running","instances","of","`","BaseTuner","`","but","only","one","`","Oracle","`",".","This","design","allows","the","user","to","run","the","same","script","on","multiple","machines","to","launch","the","parallel","tuning",".","The","`","Oracle","`","instance","should","manage","the","life","cycles","of","all","the","`","Trial","`","s",",","while","a","`","BaseTuner","`","is","a","worker","for","running","the","`","Trial","`","s",".","`","BaseTuner","`","s","requests","`","Trial","`","s","from","the","`","Oracle","`",",","run","them",",","and","report","the","results","back","to","the","`","Oracle","`",".","A","`","BaseTuner","`","also","handles","events","happening","during","running","the","`","Trial","`",",","like","saving","the","model",",","logging",",","error","handling",".","Other","than","these","responsibilities",",","a","`","BaseTuner","`","should","avoid","managing","a","`","Trial","`","since","the","relevant","contexts","for","a","`","Trial","`","are","in","the","`","Oracle","`",",","which","only","accessible","from","gRPC",".","The","`","BaseTuner","`","should","be","a","general","tuner","for","all","types","of","models","and","avoid","any","logic","directly","related","to","Keras",".","The","Keras","related","logics","should","be","handled","by","the","`","Tuner","`","class",",","which","is","a","subclass","of","`","BaseTuner","`",".","Args",":","oracle",":","Instance","of","Oracle","class",".","hypermodel",":","Instance","of","`","HyperModel","`","class","(","or","callable","that","takes","hyperparameters","and","returns","a","`","Model","`","instance",")",".","It","is","optional","when","`","Tuner.run_trial","(",")","`","is","overriden","and","does","not","use","`","self.hypermodel","`",".","directory",":","A","string",",","the","relative","path","to","the","working","directory",".","project_name",":","A","string",",","the","name","to","use","as","prefix","for","files","saved","by","this","Tuner",".","overwrite",":","Boolean",",","defaults","to","`","False","`",".","If","`","False","`",",","reloads","an","existing","project","of","the","same","name","if","one","is","found",".","Otherwise",",","overwrites","the","project",".","*","*","kwargs",":","Arguments","for","backward","compatibility",".","Attributes",":","remaining_trials",":","Number","of","trials","remaining",",","`","None","`","if","`","max_trials","`","is","not","set",".","This","is","useful","when","resuming","a","previously","stopped","search","."]
docstr: Populate initial search space for oracle.
  
  Keep this function as a subroutine for AutoKeras to override. The space
  may not be ready at the initialization of the tuner, but after seeing
  the training data.
  
  Build hypermodel multiple times to find all conditional hps. It
  generates hp values based on the not activated `conditional_scopes`
  found in the builds.
code: def _populate_initial_space(self):
      """Populate initial search space for oracle.
  
      Keep this function as a subroutine for AutoKeras to override. The space
      may not be ready at the initialization of the tuner, but after seeing
      the training data.
  
      Build hypermodel multiple times to find all conditional hps. It
      generates hp values based on the not activated `conditional_scopes`
      found in the builds.
      """
      if self.hypermodel is None:
          return
  
      # declare_hyperparameters is not overriden.
      hp = self.oracle.get_space()
      self.hypermodel.declare_hyperparameters(hp)
      self.oracle.update_space(hp)
      self._activate_all_conditions()
  
imports: import copy
  import os
  import traceback
  import warnings
  from keras_tuner import backend
  from keras_tuner import config
  from keras_tuner import errors
  from keras_tuner import utils
  from keras_tuner.api_export import keras_tuner_export
  from keras_tuner.distribute import utils
  from keras_tuner.engine import hypermodel
  from keras_tuner.engine import oracle
  from keras_tuner.engine import stateful
  from keras_tuner.engine import trial
  from keras_tuner.engine import tuner_utils
label_desc: Use image node_id 3 for calling the BaseTuner obj's underlying member method code with example usage: obj._populate_initial_space() without return types