class_docstr: A Model defined by inputs and outputs.
  AutoModel combines a HyperModel and a Tuner to tune the HyperModel.
  The user can use it in a similar way to a Keras model since it
  also has `fit()` and  `predict()` methods.
  
  The AutoModel has two use cases. In the first case, the user only specifies
  the input nodes and output heads of the AutoModel. The AutoModel infers the
  rest part of the model. In the second case, user can specify the high-level
  architecture of the AutoModel by connecting the Blocks with the functional
  API, which is the same as the Keras
  [functional API](https://www.tensorflow.org/guide/keras/functional).
  
  # Example
  ```python
      # The user only specifies the input nodes and output heads.
      import autokeras as ak
      ak.AutoModel(
          inputs=[ak.ImageInput(), ak.TextInput()],
          outputs=[ak.ClassificationHead(), ak.RegressionHead()]
      )
  ```
  ```python
      # The user specifies the high-level architecture.
      import autokeras as ak
      image_input = ak.ImageInput()
      image_output = ak.ImageBlock()(image_input)
      text_input = ak.TextInput()
      text_output = ak.TextBlock()(text_input)
      output = ak.Merge()([image_output, text_output])
      classification_output = ak.ClassificationHead()(output)
      regression_output = ak.RegressionHead()(output)
      ak.AutoModel(
          inputs=[image_input, text_input],
          outputs=[classification_output, regression_output]
      )
  ```
  
  # Arguments
      inputs: A list of Node instances.
          The input node(s) of the AutoModel.
      outputs: A list of Node or Head instances.
          The output node(s) or head(s) of the AutoModel.
      project_name: String. The name of the AutoModel. Defaults to
          'auto_model'.
      max_trials: Int. The maximum number of different Keras Models to try.
          The search may finish before reaching the max_trials. Defaults to
          100.
      directory: String. The path to a directory for storing the search
          outputs. Defaults to None, which would create a folder with the
          name of the AutoModel in the current directory.
      objective: String. Name of model metric to minimize
          or maximize, e.g. 'val_accuracy'. Defaults to 'val_loss'.
      tuner: String or subclass of AutoTuner. If string, it should be one of
          'greedy', 'bayesian', 'hyperband' or 'random'. It can also be a
          subclass of AutoTuner. Defaults to 'greedy'.
      overwrite: Boolean. Defaults to `False`. If `False`, reloads an existing
          project of the same name if one is found. Otherwise, overwrites the
          project.
      seed: Int. Random seed.
      max_model_size: Int. Maximum number of scalars in the parameters of a
          model. Models larger than this are rejected.
      **kwargs: Any arguments supported by keras_tuner.Tuner.
class_docstr_tok: ["A","Model","defined","by","inputs","and","outputs",".","AutoModel","combines","a","HyperModel","and","a","Tuner","to","tune","the","HyperModel",".","The","user","can","use","it","in","a","similar","way","to","a","Keras","model","since","it","also","has","`","fit","(",")","`","and","`","predict","(",")","`","methods",".","The","AutoModel","has","two","use","cases",".","In","the","first","case",",","the","user","only","specifies","the","input","nodes","and","output","heads","of","the","AutoModel",".","The","AutoModel","infers","the","rest","part","of","the","model",".","In","the","second","case",",","user","can","specify","the","high-level","architecture","of","the","AutoModel","by","connecting","the","Blocks","with","the","functional","API",",","which","is","the","same","as","the","Keras","[","functional","API","]","(","https",":","\/\/www.tensorflow.org\/guide\/keras\/functional",")",".","#","Example","``","`","python","#","The","user","only","specifies","the","input","nodes","and","output","heads",".","import","autokeras","as","ak","ak.AutoModel","(","inputs=","[","ak.ImageInput","(",")",",","ak.TextInput","(",")","]",",","outputs=","[","ak.ClassificationHead","(",")",",","ak.RegressionHead","(",")","]",")","``","`","``","`","python","#","The","user","specifies","the","high-level","architecture",".","import","autokeras","as","ak","image_input","=","ak.ImageInput","(",")","image_output","=","ak.ImageBlock","(",")","(","image_input",")","text_input","=","ak.TextInput","(",")","text_output","=","ak.TextBlock","(",")","(","text_input",")","output","=","ak.Merge","(",")","(","[","image_output",",","text_output","]",")","classification_output","=","ak.ClassificationHead","(",")","(","output",")","regression_output","=","ak.RegressionHead","(",")","(","output",")","ak.AutoModel","(","inputs=","[","image_input",",","text_input","]",",","outputs=","[","classification_output",",","regression_output","]",")","``","`","#","Arguments","inputs",":","A","list","of","Node","instances",".","The","input","node","(","s",")","of","the","AutoModel",".","outputs",":","A","list","of","Node","or","Head","instances",".","The","output","node","(","s",")","or","head","(","s",")","of","the","AutoModel",".","project_name",":","String",".","The","name","of","the","AutoModel",".","Defaults","to","'auto_model","'",".","max_trials",":","Int",".","The","maximum","number","of","different","Keras","Models","to","try",".","The","search","may","finish","before","reaching","the","max_trials",".","Defaults","to","100.","directory",":","String",".","The","path","to","a","directory","for","storing","the","search","outputs",".","Defaults","to","None",",","which","would","create","a","folder","with","the","name","of","the","AutoModel","in","the","current","directory",".","objective",":","String",".","Name","of","model","metric","to","minimize","or","maximize",",","e.g",".","'val_accuracy","'",".","Defaults","to","'val_loss","'",".","tuner",":","String","or","subclass","of","AutoTuner",".","If","string",",","it","should","be","one","of","'greedy","'",",","'bayesian","'",",","'hyperband","'","or","'random","'",".","It","can","also","be","a","subclass","of","AutoTuner",".","Defaults","to","'greedy","'",".","overwrite",":","Boolean",".","Defaults","to","`","False","`",".","If","`","False","`",",","reloads","an","existing","project","of","the","same","name","if","one","is","found",".","Otherwise",",","overwrites","the","project",".","seed",":","Int",".","Random","seed",".","max_model_size",":","Int",".","Maximum","number","of","scalars","in","the","parameters","of","a","model",".","Models","larger","than","this","are","rejected",".","*","*","kwargs",":","Any","arguments","supported","by","keras_tuner.Tuner","."]
code: def _adapt(self, dataset, hms, batch_size):
      if isinstance(dataset, tf.data.Dataset):
          sources = data_utils.unzip_dataset(dataset)
      else:
          sources = nest.flatten(dataset)
      adapted = []
      for source, hm in zip(sources, hms):
          source = hm.get_adapter().adapt(source, batch_size)
          adapted.append(source)
      if len(adapted) == 1:
          return adapted[0]
      return tf.data.Dataset.zip(tuple(adapted))
  
imports: from pathlib import Path
  from typing import List
  from typing import Optional
  from typing import Type
  from typing import Union
  import numpy
  import tensorflow
  from tensorflow import keras
  from tensorflow import nest
  from autokeras import blocks
  from autokeras import graph
  from autokeras import pipeline
  from autokeras import tuners
  from autokeras.engine import head
  from autokeras.engine import node
  from autokeras.engine import tuner
  from autokeras.nodes import Input
  from autokeras.utils import data_utils
  from autokeras.utils import utils
label_desc: Use image node_id 9 for calling the AutoModel obj's underlying member method code with example usage: obj._adapt(dataset, hms, batch_size) and returns: tf, adapted