r2.12 cherry-pick: 915884fdf5d "Check for correct `values` rank in UpperBound and LowerBound."
Refer to the original commit: https://github.com/tensorflow/tensorflow/commit/915884fdf5df34aaedd00fc6ace33a2cfdefa586