[tf.slice()] Optimize the shared validation code.
[tf.slice()] Optimize the shared validation code.

Several small microoptimizations:

* Avoid calling `OpKernelContext::input(0)` multiple times.
* Avoid calling `Tensor::flat<T>()` for each element of the begin/size vectors.
* Avoid copying the `gtl::InlinedVector<int64, 4>`s for begin/size into their out parameters.

PiperOrigin-RevId: 299833063
Change-Id: I6ef4f137458d5a0622ac09cdd78dd42885c2ae51

gautam1858/tensorflow,tensorflow/tensorflow,frreiss/tensorflow-fred,frreiss/tensorflow-fred,sarvex/tensorflow,frreiss/tensorflow-fred,tensorflow/tensorflow-pywrap_tf_optimizer,aam-at/tensorflow,gautam1858/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,yongtang/tensorflow,freedomtan/tensorflow,cxxgtxy/tensorflow,gunan/tensorflow,karllessard/tensorflow,tensorflow/tensorflow-pywrap_saved_model,petewarden/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,paolodedios/tensorflow,Intel-tensorflow/tensorflow,cxxgtxy/tensorflow,Intel-tensorflow/tensorflow,frreiss/tensorflow-fred,tensorflow/tensorflow-pywrap_tf_optimizer,davidzchen/tensorflow,sarvex/tensorflow,aldian/tensorflow,xzturn/tensorflow,gautam1858/tensorflow,tensorflow/tensorflow-pywrap_saved_model,xzturn/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,freedomtan/tensorflow,gautam1858/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,frreiss/tensorflow-fred,frreiss/tensorflow-fred,paolodedios/tensorflow,davidzchen/tensorflow,Intel-Corporation/tensorflow,paolodedios/tensorflow,yongtang/tensorflow,frreiss/tensorflow-fred,gunan/tensorflow,yongtang/tensorflow,gunan/tensorflow,freedomtan/tensorflow,freedomtan/tensorflow,yongtang/tensorflow,aam-at/tensorflow,gautam1858/tensorflow,Intel-tensorflow/tensorflow,petewarden/tensorflow,gunan/tensorflow,davidzchen/tensorflow,annarev/tensorflow,karllessard/tensorflow,tensorflow/tensorflow-pywrap_saved_model,xzturn/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,Intel-Corporation/tensorflow,petewarden/tensorflow,freedomtan/tensorflow,aam-at/tensorflow,tensorflow/tensorflow,yongtang/tensorflow,gautam1858/tensorflow,davidzchen/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,xzturn/tensorflow,karllessard/tensorflow,gunan/tensorflow,frreiss/tensorflow-fred,cxxgtxy/tensorflow,cxxgtxy/tensorflow,petewarden/tensorflow,aam-at/tensorflow,freedomtan/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,xzturn/tensorflow,Intel-tensorflow/tensorflow,freedomtan/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,Intel-Corporation/tensorflow,sarvex/tensorflow,tensorflow/tensorflow-pywrap_saved_model,davidzchen/tensorflow,aldian/tensorflow,annarev/tensorflow,paolodedios/tensorflow,aldian/tensorflow,petewarden/tensorflow,Intel-Corporation/tensorflow,paolodedios/tensorflow,petewarden/tensorflow,karllessard/tensorflow,davidzchen/tensorflow,tensorflow/tensorflow-pywrap_saved_model,Intel-Corporation/tensorflow,cxxgtxy/tensorflow,frreiss/tensorflow-fred,freedomtan/tensorflow,tensorflow/tensorflow-pywrap_saved_model,gautam1858/tensorflow,annarev/tensorflow,freedomtan/tensorflow,xzturn/tensorflow,aldian/tensorflow,paolodedios/tensorflow,sarvex/tensorflow,xzturn/tensorflow,tensorflow/tensorflow,paolodedios/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,yongtang/tensorflow,davidzchen/tensorflow,annarev/tensorflow,xzturn/tensorflow,annarev/tensorflow,gunan/tensorflow,yongtang/tensorflow,aam-at/tensorflow,karllessard/tensorflow,petewarden/tensorflow,annarev/tensorflow,davidzchen/tensorflow,aldian/tensorflow,tensorflow/tensorflow-pywrap_saved_model,davidzchen/tensorflow,davidzchen/tensorflow,paolodedios/tensorflow,karllessard/tensorflow,karllessard/tensorflow,aam-at/tensorflow,xzturn/tensorflow,paolodedios/tensorflow,frreiss/tensorflow-fred,petewarden/tensorflow,annarev/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,tensorflow/tensorflow-experimental_link_static_libraries_once,Intel-Corporation/tensorflow,Intel-Corporation/tensorflow,Intel-tensorflow/tensorflow,petewarden/tensorflow,davidzchen/tensorflow,davidzchen/tensorflow,tensorflow/tensorflow,annarev/tensorflow,xzturn/tensorflow,xzturn/tensorflow,aldian/tensorflow,gunan/tensorflow,tensorflow/tensorflow,gunan/tensorflow,petewarden/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,paolodedios/tensorflow,tensorflow/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,tensorflow/tensorflow-experimental_link_static_libraries_once,tensorflow/tensorflow,sarvex/tensorflow,sarvex/tensorflow,aam-at/tensorflow,petewarden/tensorflow,aldian/tensorflow,gautam1858/tensorflow,sarvex/tensorflow,aldian/tensorflow,annarev/tensorflow,freedomtan/tensorflow,tensorflow/tensorflow,cxxgtxy/tensorflow,paolodedios/tensorflow,gunan/tensorflow,Intel-tensorflow/tensorflow,karllessard/tensorflow,frreiss/tensorflow-fred,tensorflow/tensorflow,frreiss/tensorflow-fred,tensorflow/tensorflow,tensorflow/tensorflow,freedomtan/tensorflow,cxxgtxy/tensorflow,gautam1858/tensorflow,gunan/tensorflow,tensorflow/tensorflow-pywrap_saved_model,aam-at/tensorflow,Intel-tensorflow/tensorflow,gautam1858/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,tensorflow/tensorflow-pywrap_tf_optimizer,gautam1858/tensorflow,tensorflow/tensorflow-pywrap_saved_model,Intel-tensorflow/tensorflow,freedomtan/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,karllessard/tensorflow,aam-at/tensorflow,annarev/tensorflow,aam-at/tensorflow,aam-at/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,gunan/tensorflow,Intel-Corporation/tensorflow,petewarden/tensorflow,yongtang/tensorflow,Intel-tensorflow/tensorflow,Intel-tensorflow/tensorflow,tensorflow/tensorflow-pywrap_saved_model,tensorflow/tensorflow-pywrap_saved_model,karllessard/tensorflow,Intel-tensorflow/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,cxxgtxy/tensorflow,yongtang/tensorflow,xzturn/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,gautam1858/tensorflow,yongtang/tensorflow,annarev/tensorflow,yongtang/tensorflow,gunan/tensorflow,karllessard/tensorflow,aam-at/tensorflow,sarvex/tensorflow