You should not post code solutions in here, but I guess this is just mock.
Yes the dropout layer should be used when there are many neurons, so some of them are shut down and let the flow go through the rest of the neurons. Think of it like a stream of water going through many channels, if there are many pipes there want be much water in either of the channels (in our case the weights will become very small and have little effect to transforming the input to a desired output). So, a dropout in the beginning where there are just a few neurons doesn’t make sense.