During the training your custom dropout layer would only return the scaled drop mask without the input, while during evaluation nothing would be returned.
Could you post the complete stack trace for the flatten error?