Compute `dropout_probability` only in training mode
# What does this PR do?

Same issue as in #24483 (caused by #24434 ), but with a different fix. For core maintainers to decide which one is better.

If we decide to go this way, I will do fix-copies.
_The documentation is not available anymore as the PR was closed or merged._