r2.11 cherry-pick: 62efa487713 "[TFG] Fix index out of bound issue in TFG shape inference pass."
Refer to the original commit: https://github.com/tensorflow/tensorflow/commit/62efa487713692ef22b055f19d622f4ab6d2ab7e