'Adds a layer instance on top of the layer stack.
# Arguments
layer: layer instance.
# Raises
TypeError: If `layer` is not a layer instance.
ValueError: In case the `layer` argument does not
know its input shape.
ValueError: In case the `layer` argument has
multiple output tensors, or is already connected
somewhere else (forbidden in `Sequential` models).'

def add(self, layer):

    if (not isinstance(layer, Layer)):
        raise TypeError(('The    added    layer    must    be    an    instance    of    class    Layer.    Found:    ' + str(layer)))
    if (not self.outputs):
        if (not layer.inbound_nodes):
            if (not hasattr(layer, 'batch_input_shape')):
                raise ValueError('The    first    layer    in    a    Sequential    model    must    get    an    `input_shape`    or    `batch_input_shape`    argument.')
            x = Input(batch_shape=layer.batch_input_shape, dtype=layer.dtype, name=(layer.name + '_input'))
            layer(x)
        if (len(layer.inbound_nodes) != 1):
            raise ValueError((((('A    layer    added    to    a    Sequential    model    must    not    already    be    connected    somewhere    else.    Model    received    layer    ' + layer.name) + '    which    has    ') + str(len(layer.inbound_nodes))) + '    pre-existing    inbound    connections.'))
        if (len(layer.inbound_nodes[0].output_tensors) != 1):
            raise ValueError('All    layers    in    a    Sequential    model    should    have    a    single    output    tensor.    For    multi-output    layers,    use    the    functional    API.')
        self.outputs = [layer.inbound_nodes[0].output_tensors[0]]
        self.inputs = topology.get_source_inputs(self.outputs[0])
        topology.Node(outbound_layer=self, inbound_layers=[], node_indices=[], tensor_indices=[], input_tensors=self.inputs, output_tensors=self.outputs, input_masks=[None for _ in self.inputs], output_masks=[None], input_shapes=[x._keras_shape for x in self.inputs], output_shapes=[self.outputs[0]._keras_shape])
    else:
        output_tensor = layer(self.outputs[0])
        if isinstance(output_tensor, list):
            raise TypeError('All    layers    in    a    Sequential    model    should    have    a    single    output    tensor.    For    multi-output    layers,    use    the    functional    API.')
        self.outputs = [output_tensor]
        self.inbound_nodes[0].output_tensors = self.outputs
        self.inbound_nodes[0].output_shapes = [self.outputs[0]._keras_shape]
    self.layers.append(layer)
    self.built = False
