Keras does this by default. In Keras dropout is disabled in test mode. You can use the dropped input in training and the actual input while testing.
You have to build your own training function from the layers and specify the training flag to predict with dropout (e.g. it's not possible to specify a training flag for the predict functions). You want to do GANs, which use the intermediate output for training and also train the network as a whole, due to a divergence between generated training images and generated test images.
Hope this answer helps you!
If you want to know more about Machine Learning then watch this video: