fix cudnn RNN reproducibility problem (#90522)
Fixes #74177
Since RNN code use static variables to cache state, we store an atomic_flag in RNG generator to notify new seed changes and generate new random state for RNN. The additional cost is that the it must check the atomic_flag each time to ensure reproducibility. This may be ugly but it is the best way currently without large code refactoring
Pull Request resolved: https://github.com/pytorch/pytorch/pull/90522
Approved by: https://github.com/ngimel