It looks like the fundamental problem here is that you are using a mix of the Sequential Model (from the first section) and the Functional Model. But the two don’t mix. Here in the second section we are doing the Functional API, so there are no commas between the layers: each line is the invocation of a function with an input and an output. Then for some layers (e.g. Dense), you only instantiate the layer function, but don’t actually call it with an input, which is the source of that specific error message. But there is plenty else wrong here: if you only fix that, you’ll start getting dimension errors and the like.
The instructions here are not all that useful at explaining how the two Keras APIs work, but here’s a very useful thread from ai_curious that walks you through some examples of both and explains what is going on. Please have a look and that should clarify my comments above, if they don’t make sense the first time.