The tensor must be passed to the layer when you are calling it, and not as an argument. Therefore it must be like this:
x = Flatten()(x) # first the layer is constructed and then it is called on x
To make it more clear, it is equivalent to this:
flatten_layer = Flatten() # instantiate the layer
x = flatten_layer(x) # call it on the given tensor