class_docstr: `Sequential` groups a linear stack of layers into a `Model`.
  
  Examples:
  
  ```python
  model = keras.Sequential()
  model.add(keras.Input(shape=(16,)))
  model.add(keras.layers.Dense(8))
  
  # Note that you can also omit the initial `Input`.
  # In that case the model doesn't have any weights until the first call
  # to a training/evaluation method (since it isn't yet built):
  model = keras.Sequential()
  model.add(keras.layers.Dense(8))
  model.add(keras.layers.Dense(4))
  # model.weights not created yet
  
  # Whereas if you specify an `Input`, the model gets built
  # continuously as you are adding layers:
  model = keras.Sequential()
  model.add(keras.Input(shape=(16,)))
  model.add(keras.layers.Dense(8))
  len(model.weights)  # Returns "2"
  
  # When using the delayed-build pattern (no input shape specified), you can
  # choose to manually build your model by calling
  # `build(batch_input_shape)`:
  model = keras.Sequential()
  model.add(keras.layers.Dense(8))
  model.add(keras.layers.Dense(4))
  model.build((None, 16))
  len(model.weights)  # Returns "4"
  
  # Note that when using the delayed-build pattern (no input shape specified),
  # the model gets built the first time you call `fit`, `eval`, or `predict`,
  # or the first time you call the model on some input data.
  model = keras.Sequential()
  model.add(keras.layers.Dense(8))
  model.add(keras.layers.Dense(1))
  model.compile(optimizer='sgd', loss='mse')
  # This builds the model for the first time:
  model.fit(x, y, batch_size=32, epochs=10)
  ```
class_docstr_tok: ["`","Sequential","`","groups","a","linear","stack","of","layers","into","a","`","Model","`",".","Examples",":","``","`","python","model","=","keras.Sequential","(",")","model.add","(","keras.Input","(","shape=","(","16",",",")",")",")","model.add","(","keras.layers.Dense","(","8",")",")","#","Note","that","you","can","also","omit","the","initial","`","Input","`",".","#","In","that","case","the","model","does","n't","have","any","weights","until","the","first","call","#","to","a","training\/evaluation","method","(","since","it","is","n't","yet","built",")",":","model","=","keras.Sequential","(",")","model.add","(","keras.layers.Dense","(","8",")",")","model.add","(","keras.layers.Dense","(","4",")",")","#","model.weights","not","created","yet","#","Whereas","if","you","specify","an","`","Input","`",",","the","model","gets","built","#","continuously","as","you","are","adding","layers",":","model","=","keras.Sequential","(",")","model.add","(","keras.Input","(","shape=","(","16",",",")",")",")","model.add","(","keras.layers.Dense","(","8",")",")","len","(","model.weights",")","#","Returns","``","2","''","#","When","using","the","delayed-build","pattern","(","no","input","shape","specified",")",",","you","can","#","choose","to","manually","build","your","model","by","calling","#","`","build","(","batch_input_shape",")","`",":","model","=","keras.Sequential","(",")","model.add","(","keras.layers.Dense","(","8",")",")","model.add","(","keras.layers.Dense","(","4",")",")","model.build","(","(","None",",","16",")",")","len","(","model.weights",")","#","Returns","``","4","''","#","Note","that","when","using","the","delayed-build","pattern","(","no","input","shape","specified",")",",","#","the","model","gets","built","the","first","time","you","call","`","fit","`",",","`","eval","`",",","or","`","predict","`",",","#","or","the","first","time","you","call","the","model","on","some","input","data",".","model","=","keras.Sequential","(",")","model.add","(","keras.layers.Dense","(","8",")",")","model.add","(","keras.layers.Dense","(","1",")",")","model.compile","(","optimizer='sgd","'",",","loss='mse","'",")","#","This","builds","the","model","for","the","first","time",":","model.fit","(","x",",","y",",","batch_size=32",",","epochs=10",")","``","`"]
code: def build(self, input_shape=None):
      if not isinstance(input_shape, (tuple, list)):
          # Do not attempt to build if the model does not have a single
          # input tensor.
          return
      if input_shape and not (
          isinstance(input_shape[0], int) or input_shape[0] is None
      ):
          # Do not attempt to build if the model does not have a single
          # input tensor.
          return
      if not self._layers:
          raise ValueError(
              f"Sequential model {self.name} cannot be built because it has "
              "no layers. Call `model.add(layer)`."
          )
      if isinstance(self._layers[0], InputLayer):
          if self._layers[0].batch_shape != input_shape:
              raise ValueError(
                  f"Sequential model '{self.name}' has already been "
                  "configured to use input shape "
                  f"{self._layers[0].batch_shape}. You cannot build it "
                  f"with input_shape {input_shape}"
              )
      else:
          dtype = self._layers[0].compute_dtype
          self._layers = [
              InputLayer(batch_shape=input_shape, dtype=dtype)
          ] + self._layers
  
      # Build functional model
      inputs = self._layers[0].output
      x = inputs
      for layer in self._layers[1:]:
          try:
              x = layer(x)
          except NotImplementedError:
              # Can happen if shape inference is not implemented.
              # TODO: consider reverting inbound nodes on layers processed.
              return
          except TypeError as e:
              signature = inspect.signature(layer.call)
              positional_args = [
                  param
                  for param in signature.parameters.values()
                  if param.default == inspect.Parameter.empty
              ]
              if len(positional_args) != 1:
                  raise ValueError(
                      "Layers added to a Sequential model "
                      "can only have a single positional argument, "
                      f"the input tensor. Layer {layer.__class__.__name__} "
                      f"has multiple positional arguments: {positional_args}"
                  )
              raise e
      outputs = x
      self._functional = Functional(inputs=inputs, outputs=outputs)
      self.built = True
  
imports: import copy
  import inspect
  import tree
  from keras.api_export import keras_export
  from keras.backend.common import global_state
  from keras.layers.core.input_layer import InputLayer
  from keras.layers.layer import Layer
  from keras.legacy.saving import saving_utils
  from keras.legacy.saving import serialization
  from keras.models.functional import Functional
  from keras.models.model import Model
  from keras.saving import serialization_lib
label_desc: Use image node_id 6 for calling the Sequential obj's underlying member method code with example usage: obj.build(input_shape) without return types