class_docstr: A Tuner class based on KerasTuner for AutoKeras.
  
  Different from KerasTuner's Tuner class. AutoTuner's not only tunes the
  Hypermodel which can be directly built into a Keras model, but also the
  preprocessors. Therefore, a HyperGraph stores the overall search space
  containing both the Preprocessors and Hypermodel. For every trial, the
  HyperGraph builds the PreprocessGraph and KerasGraph with the provided
  HyperParameters.
  
  The AutoTuner uses EarlyStopping for acceleration during the search and
  fully trains the model with full epochs and with both training and
  validation data.  The fully trained model is the best model to be used by
  AutoModel.
  
  # Arguments
      oracle: keras_tuner Oracle.
      hypermodel: keras_tuner HyperModel.
      **kwargs: The args supported by KerasTuner.
docstr: Adapt the preprocessing layers in the model.
docstr_tok: ["Adapt","the","preprocessing","layers","in","the","model","."]
code: def adapt(model, dataset):
      """Adapt the preprocessing layers in the model."""
      # Currently, only support using the original dataset to adapt all the
      # preprocessing layers before the first non-preprocessing layer.
      # TODO: Use PreprocessingStage for preprocessing layers adapt.
      # TODO: Use Keras Tuner for preprocessing layers adapt.
      x = dataset.map(lambda x, y: x)
  
      def get_output_layers(tensor):
          output_layers = []
          tensor = nest.flatten(tensor)[0]
          for layer in model.layers:
              if isinstance(layer, keras.layers.InputLayer):
                  continue
              input_node = nest.flatten(layer.input)[0]
              if input_node is tensor:
                  if isinstance(
                      layer, preprocessing.PreprocessingLayer
                  ):
                      output_layers.append(layer)
          return output_layers
  
      dq = collections.deque()
  
      for index, input_node in enumerate(nest.flatten(model.input)):
          in_x = x.map(lambda *args: nest.flatten(args)[index])
          for layer in get_output_layers(input_node):
              dq.append((layer, in_x))
  
      while len(dq):
          layer, in_x = dq.popleft()
          layer.adapt(in_x)
          out_x = in_x.map(layer)
          for next_layer in get_output_layers(layer.output):
              dq.append((next_layer, out_x))
  
      return model
  
imports: import collections
  import copy
  import os
  import keras_tuner
  from tensorflow import keras
  from tensorflow import nest
  from tensorflow.keras import callbacks
  from tensorflow.keras.layers.experimental import preprocessing
  from autokeras import pipeline
  from autokeras.utils import data_utils
  from autokeras.utils import utils
label_desc: Use image node_id 8 for calling the AutoTuner obj's underlying member method code with example usage: obj.adapt(model, dataset) and returns: model, output_layers