r2.11 cherry-pick: d80293c5b5e "Fix memory corruption vulnerability in reverse_sequence_op."
Refer to the original commit: https://github.com/tensorflow/tensorflow/commit/d80293c5b5e403f52df28395a146a75dd3054bb8