Minor refactor of _WhileBodyGradFuncGraph._capture_helper.
Minor refactor of _WhileBodyGradFuncGraph._capture_helper.

It was getting kind of long. This also makes minor stylistic changes to the moved code.

PiperOrigin-RevId: 228804655

alsrgv/tensorflow,jhseu/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,DavidNorman/tensorflow,adit-chandra/tensorflow,karllessard/tensorflow,ageron/tensorflow,DavidNorman/tensorflow,yongtang/tensorflow,gunan/tensorflow,tensorflow/tensorflow-pywrap_saved_model,arborh/tensorflow,alsrgv/tensorflow,jbedorf/tensorflow,ghchinoy/tensorflow,Intel-Corporation/tensorflow,adit-chandra/tensorflow,adit-chandra/tensorflow,DavidNorman/tensorflow,tensorflow/tensorflow-pywrap_saved_model,ppwwyyxx/tensorflow,DavidNorman/tensorflow,xzturn/tensorflow,frreiss/tensorflow-fred,theflofly/tensorflow,alsrgv/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,ghchinoy/tensorflow,aam-at/tensorflow,freedomtan/tensorflow,theflofly/tensorflow,ppwwyyxx/tensorflow,tensorflow/tensorflow,yongtang/tensorflow,annarev/tensorflow,yongtang/tensorflow,adit-chandra/tensorflow,yongtang/tensorflow,xzturn/tensorflow,tensorflow/tensorflow,annarev/tensorflow,cxxgtxy/tensorflow,chemelnucfin/tensorflow,frreiss/tensorflow-fred,alsrgv/tensorflow,frreiss/tensorflow-fred,jhseu/tensorflow,cxxgtxy/tensorflow,ghchinoy/tensorflow,ppwwyyxx/tensorflow,tensorflow/tensorflow,ghchinoy/tensorflow,karllessard/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,jbedorf/tensorflow,renyi533/tensorflow,xzturn/tensorflow,paolodedios/tensorflow,chemelnucfin/tensorflow,annarev/tensorflow,jendap/tensorflow,DavidNorman/tensorflow,freedomtan/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,paolodedios/tensorflow,gunan/tensorflow,ageron/tensorflow,jendap/tensorflow,annarev/tensorflow,adit-chandra/tensorflow,chemelnucfin/tensorflow,karllessard/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,yongtang/tensorflow,DavidNorman/tensorflow,jendap/tensorflow,freedomtan/tensorflow,aam-at/tensorflow,arborh/tensorflow,davidzchen/tensorflow,jendap/tensorflow,ghchinoy/tensorflow,aldian/tensorflow,tensorflow/tensorflow,jbedorf/tensorflow,xzturn/tensorflow,davidzchen/tensorflow,jbedorf/tensorflow,ppwwyyxx/tensorflow,petewarden/tensorflow,aam-at/tensorflow,davidzchen/tensorflow,xzturn/tensorflow,davidzchen/tensorflow,apark263/tensorflow,Intel-tensorflow/tensorflow,jhseu/tensorflow,Intel-Corporation/tensorflow,annarev/tensorflow,davidzchen/tensorflow,cxxgtxy/tensorflow,xzturn/tensorflow,karllessard/tensorflow,annarev/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,tensorflow/tensorflow-experimental_link_static_libraries_once,ppwwyyxx/tensorflow,jbedorf/tensorflow,DavidNorman/tensorflow,petewarden/tensorflow,jhseu/tensorflow,freedomtan/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,alsrgv/tensorflow,tensorflow/tensorflow-pywrap_saved_model,jbedorf/tensorflow,chemelnucfin/tensorflow,DavidNorman/tensorflow,cxxgtxy/tensorflow,alsrgv/tensorflow,adit-chandra/tensorflow,freedomtan/tensorflow,ageron/tensorflow,tensorflow/tensorflow,tensorflow/tensorflow,frreiss/tensorflow-fred,freedomtan/tensorflow,gautam1858/tensorflow,paolodedios/tensorflow,arborh/tensorflow,arborh/tensorflow,xzturn/tensorflow,petewarden/tensorflow,tensorflow/tensorflow-pywrap_saved_model,paolodedios/tensorflow,DavidNorman/tensorflow,gautam1858/tensorflow,gunan/tensorflow,annarev/tensorflow,DavidNorman/tensorflow,petewarden/tensorflow,kevin-coder/tensorflow-fork,yongtang/tensorflow,apark263/tensorflow,renyi533/tensorflow,gautam1858/tensorflow,aldian/tensorflow,jhseu/tensorflow,theflofly/tensorflow,DavidNorman/tensorflow,adit-chandra/tensorflow,tensorflow/tensorflow,ageron/tensorflow,tensorflow/tensorflow,jendap/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,tensorflow/tensorflow-pywrap_saved_model,DavidNorman/tensorflow,Intel-tensorflow/tensorflow,jendap/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,jbedorf/tensorflow,Intel-tensorflow/tensorflow,arborh/tensorflow,xzturn/tensorflow,gunan/tensorflow,tensorflow/tensorflow-pywrap_saved_model,ageron/tensorflow,paolodedios/tensorflow,chemelnucfin/tensorflow,karllessard/tensorflow,gautam1858/tensorflow,cxxgtxy/tensorflow,annarev/tensorflow,Intel-tensorflow/tensorflow,ghchinoy/tensorflow,renyi533/tensorflow,gunan/tensorflow,aam-at/tensorflow,cxxgtxy/tensorflow,karllessard/tensorflow,davidzchen/tensorflow,Intel-Corporation/tensorflow,alsrgv/tensorflow,freedomtan/tensorflow,apark263/tensorflow,cxxgtxy/tensorflow,apark263/tensorflow,apark263/tensorflow,karllessard/tensorflow,apark263/tensorflow,renyi533/tensorflow,davidzchen/tensorflow,ageron/tensorflow,gunan/tensorflow,freedomtan/tensorflow,arborh/tensorflow,ghchinoy/tensorflow,chemelnucfin/tensorflow,kevin-coder/tensorflow-fork,aam-at/tensorflow,petewarden/tensorflow,aam-at/tensorflow,paolodedios/tensorflow,gunan/tensorflow,jhseu/tensorflow,jbedorf/tensorflow,davidzchen/tensorflow,yongtang/tensorflow,karllessard/tensorflow,theflofly/tensorflow,petewarden/tensorflow,jendap/tensorflow,ageron/tensorflow,jhseu/tensorflow,chemelnucfin/tensorflow,arborh/tensorflow,Intel-tensorflow/tensorflow,sarvex/tensorflow,karllessard/tensorflow,arborh/tensorflow,theflofly/tensorflow,adit-chandra/tensorflow,petewarden/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,chemelnucfin/tensorflow,paolodedios/tensorflow,Intel-Corporation/tensorflow,renyi533/tensorflow,sarvex/tensorflow,karllessard/tensorflow,ageron/tensorflow,jhseu/tensorflow,annarev/tensorflow,kevin-coder/tensorflow-fork,Intel-tensorflow/tensorflow,xzturn/tensorflow,adit-chandra/tensorflow,annarev/tensorflow,paolodedios/tensorflow,ppwwyyxx/tensorflow,yongtang/tensorflow,Intel-Corporation/tensorflow,chemelnucfin/tensorflow,Intel-Corporation/tensorflow,yongtang/tensorflow,apark263/tensorflow,kevin-coder/tensorflow-fork,alsrgv/tensorflow,tensorflow/tensorflow-pywrap_saved_model,tensorflow/tensorflow-experimental_link_static_libraries_once,apark263/tensorflow,aldian/tensorflow,theflofly/tensorflow,jbedorf/tensorflow,arborh/tensorflow,arborh/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,aam-at/tensorflow,alsrgv/tensorflow,ageron/tensorflow,apark263/tensorflow,renyi533/tensorflow,aldian/tensorflow,ghchinoy/tensorflow,kevin-coder/tensorflow-fork,tensorflow/tensorflow-pywrap_saved_model,jendap/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,ghchinoy/tensorflow,ageron/tensorflow,gunan/tensorflow,frreiss/tensorflow-fred,ppwwyyxx/tensorflow,jhseu/tensorflow,Intel-tensorflow/tensorflow,petewarden/tensorflow,gunan/tensorflow,ppwwyyxx/tensorflow,ageron/tensorflow,aldian/tensorflow,arborh/tensorflow,gautam1858/tensorflow,jbedorf/tensorflow,jhseu/tensorflow,paolodedios/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,yongtang/tensorflow,gunan/tensorflow,sarvex/tensorflow,frreiss/tensorflow-fred,tensorflow/tensorflow,cxxgtxy/tensorflow,gautam1858/tensorflow,theflofly/tensorflow,xzturn/tensorflow,tensorflow/tensorflow,davidzchen/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,aam-at/tensorflow,ppwwyyxx/tensorflow,jhseu/tensorflow,annarev/tensorflow,jbedorf/tensorflow,adit-chandra/tensorflow,arborh/tensorflow,tensorflow/tensorflow-pywrap_saved_model,gautam1858/tensorflow,Intel-Corporation/tensorflow,davidzchen/tensorflow,alsrgv/tensorflow,Intel-tensorflow/tensorflow,Intel-Corporation/tensorflow,davidzchen/tensorflow,tensorflow/tensorflow,theflofly/tensorflow,ghchinoy/tensorflow,gautam1858/tensorflow,aldian/tensorflow,xzturn/tensorflow,theflofly/tensorflow,gautam1858/tensorflow,petewarden/tensorflow,gunan/tensorflow,aam-at/tensorflow,davidzchen/tensorflow,jendap/tensorflow,paolodedios/tensorflow,frreiss/tensorflow-fred,apark263/tensorflow,adit-chandra/tensorflow,gautam1858/tensorflow,ppwwyyxx/tensorflow,kevin-coder/tensorflow-fork,petewarden/tensorflow,jendap/tensorflow,sarvex/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,tensorflow/tensorflow-pywrap_tf_optimizer,gautam1858/tensorflow,aam-at/tensorflow,frreiss/tensorflow-fred,kevin-coder/tensorflow-fork,Intel-tensorflow/tensorflow,tensorflow/tensorflow-pywrap_saved_model,tensorflow/tensorflow-pywrap_tf_optimizer,frreiss/tensorflow-fred,apark263/tensorflow,freedomtan/tensorflow,adit-chandra/tensorflow,aam-at/tensorflow,kevin-coder/tensorflow-fork,frreiss/tensorflow-fred,sarvex/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,alsrgv/tensorflow,alsrgv/tensorflow,tensorflow/tensorflow-pywrap_saved_model,chemelnucfin/tensorflow,chemelnucfin/tensorflow,gautam1858/tensorflow,aam-at/tensorflow,jendap/tensorflow,aldian/tensorflow,sarvex/tensorflow,ppwwyyxx/tensorflow,theflofly/tensorflow,renyi533/tensorflow,chemelnucfin/tensorflow,renyi533/tensorflow,jhseu/tensorflow,renyi533/tensorflow,freedomtan/tensorflow,ghchinoy/tensorflow,kevin-coder/tensorflow-fork,tensorflow/tensorflow-pywrap_tf_optimizer,renyi533/tensorflow,theflofly/tensorflow,frreiss/tensorflow-fred,frreiss/tensorflow-fred,ppwwyyxx/tensorflow,ageron/tensorflow,petewarden/tensorflow,Intel-tensorflow/tensorflow,kevin-coder/tensorflow-fork,renyi533/tensorflow,Intel-tensorflow/tensorflow,karllessard/tensorflow,theflofly/tensorflow,sarvex/tensorflow,kevin-coder/tensorflow-fork,renyi533/tensorflow,freedomtan/tensorflow,petewarden/tensorflow,sarvex/tensorflow,jbedorf/tensorflow,yongtang/tensorflow,aldian/tensorflow,freedomtan/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,xzturn/tensorflow,paolodedios/tensorflow,gunan/tensorflow,ghchinoy/tensorflow