In _GradientsHelper() compute the ObjectIdentitySet(xs) once and reuse it.
In _GradientsHelper() compute the ObjectIdentitySet(xs) once and reuse it.

This avoids a potentially quadratic execution time in building the gradient graph, because we were previously creating the set multiple times for each op in the graph.

PiperOrigin-RevId: 264826531

chemelnucfin/tensorflow,jhseu/tensorflow,yongtang/tensorflow,karllessard/tensorflow,aldian/tensorflow,chemelnucfin/tensorflow,freedomtan/tensorflow,adit-chandra/tensorflow,DavidNorman/tensorflow,gautam1858/tensorflow,arborh/tensorflow,chemelnucfin/tensorflow,aldian/tensorflow,paolodedios/tensorflow,tensorflow/tensorflow-pywrap_saved_model,petewarden/tensorflow,annarev/tensorflow,gautam1858/tensorflow,tensorflow/tensorflow-pywrap_saved_model,aam-at/tensorflow,sarvex/tensorflow,adit-chandra/tensorflow,frreiss/tensorflow-fred,tensorflow/tensorflow,gunan/tensorflow,paolodedios/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,tensorflow/tensorflow,petewarden/tensorflow,davidzchen/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,tensorflow/tensorflow-pywrap_tf_optimizer,renyi533/tensorflow,xzturn/tensorflow,davidzchen/tensorflow,freedomtan/tensorflow,DavidNorman/tensorflow,arborh/tensorflow,davidzchen/tensorflow,DavidNorman/tensorflow,Intel-tensorflow/tensorflow,karllessard/tensorflow,chemelnucfin/tensorflow,cxxgtxy/tensorflow,petewarden/tensorflow,karllessard/tensorflow,renyi533/tensorflow,annarev/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,annarev/tensorflow,freedomtan/tensorflow,yongtang/tensorflow,adit-chandra/tensorflow,petewarden/tensorflow,yongtang/tensorflow,DavidNorman/tensorflow,jhseu/tensorflow,tensorflow/tensorflow-pywrap_saved_model,aam-at/tensorflow,yongtang/tensorflow,gautam1858/tensorflow,chemelnucfin/tensorflow,renyi533/tensorflow,chemelnucfin/tensorflow,annarev/tensorflow,aam-at/tensorflow,annarev/tensorflow,ppwwyyxx/tensorflow,ppwwyyxx/tensorflow,frreiss/tensorflow-fred,ppwwyyxx/tensorflow,gunan/tensorflow,petewarden/tensorflow,yongtang/tensorflow,aam-at/tensorflow,tensorflow/tensorflow-pywrap_saved_model,DavidNorman/tensorflow,DavidNorman/tensorflow,ppwwyyxx/tensorflow,aam-at/tensorflow,Intel-tensorflow/tensorflow,tensorflow/tensorflow-pywrap_saved_model,aam-at/tensorflow,yongtang/tensorflow,renyi533/tensorflow,arborh/tensorflow,paolodedios/tensorflow,frreiss/tensorflow-fred,ppwwyyxx/tensorflow,paolodedios/tensorflow,gautam1858/tensorflow,aldian/tensorflow,chemelnucfin/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,xzturn/tensorflow,xzturn/tensorflow,frreiss/tensorflow-fred,renyi533/tensorflow,karllessard/tensorflow,Intel-Corporation/tensorflow,Intel-tensorflow/tensorflow,gautam1858/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,freedomtan/tensorflow,chemelnucfin/tensorflow,freedomtan/tensorflow,adit-chandra/tensorflow,aldian/tensorflow,yongtang/tensorflow,Intel-Corporation/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,renyi533/tensorflow,karllessard/tensorflow,chemelnucfin/tensorflow,petewarden/tensorflow,davidzchen/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,adit-chandra/tensorflow,Intel-tensorflow/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,tensorflow/tensorflow-pywrap_tf_optimizer,frreiss/tensorflow-fred,tensorflow/tensorflow-pywrap_tf_optimizer,gunan/tensorflow,arborh/tensorflow,sarvex/tensorflow,jhseu/tensorflow,adit-chandra/tensorflow,renyi533/tensorflow,aam-at/tensorflow,DavidNorman/tensorflow,paolodedios/tensorflow,yongtang/tensorflow,sarvex/tensorflow,freedomtan/tensorflow,yongtang/tensorflow,xzturn/tensorflow,aam-at/tensorflow,davidzchen/tensorflow,freedomtan/tensorflow,chemelnucfin/tensorflow,jhseu/tensorflow,gunan/tensorflow,frreiss/tensorflow-fred,karllessard/tensorflow,jhseu/tensorflow,frreiss/tensorflow-fred,petewarden/tensorflow,davidzchen/tensorflow,arborh/tensorflow,xzturn/tensorflow,freedomtan/tensorflow,frreiss/tensorflow-fred,arborh/tensorflow,yongtang/tensorflow,aam-at/tensorflow,xzturn/tensorflow,tensorflow/tensorflow-pywrap_saved_model,xzturn/tensorflow,jhseu/tensorflow,paolodedios/tensorflow,frreiss/tensorflow-fred,renyi533/tensorflow,petewarden/tensorflow,cxxgtxy/tensorflow,tensorflow/tensorflow,DavidNorman/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,Intel-tensorflow/tensorflow,cxxgtxy/tensorflow,jhseu/tensorflow,cxxgtxy/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,xzturn/tensorflow,adit-chandra/tensorflow,davidzchen/tensorflow,petewarden/tensorflow,renyi533/tensorflow,Intel-tensorflow/tensorflow,gunan/tensorflow,arborh/tensorflow,gautam1858/tensorflow,tensorflow/tensorflow-pywrap_saved_model,tensorflow/tensorflow,tensorflow/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,karllessard/tensorflow,DavidNorman/tensorflow,gautam1858/tensorflow,davidzchen/tensorflow,arborh/tensorflow,Intel-tensorflow/tensorflow,paolodedios/tensorflow,jhseu/tensorflow,gunan/tensorflow,karllessard/tensorflow,sarvex/tensorflow,davidzchen/tensorflow,sarvex/tensorflow,adit-chandra/tensorflow,freedomtan/tensorflow,tensorflow/tensorflow,aldian/tensorflow,xzturn/tensorflow,adit-chandra/tensorflow,Intel-tensorflow/tensorflow,petewarden/tensorflow,gautam1858/tensorflow,jhseu/tensorflow,arborh/tensorflow,renyi533/tensorflow,cxxgtxy/tensorflow,cxxgtxy/tensorflow,chemelnucfin/tensorflow,davidzchen/tensorflow,annarev/tensorflow,adit-chandra/tensorflow,aam-at/tensorflow,renyi533/tensorflow,yongtang/tensorflow,petewarden/tensorflow,karllessard/tensorflow,tensorflow/tensorflow,gautam1858/tensorflow,gautam1858/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,ppwwyyxx/tensorflow,tensorflow/tensorflow-pywrap_saved_model,arborh/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,arborh/tensorflow,gautam1858/tensorflow,gunan/tensorflow,gunan/tensorflow,Intel-Corporation/tensorflow,frreiss/tensorflow-fred,freedomtan/tensorflow,Intel-tensorflow/tensorflow,DavidNorman/tensorflow,DavidNorman/tensorflow,adit-chandra/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,tensorflow/tensorflow,chemelnucfin/tensorflow,adit-chandra/tensorflow,Intel-Corporation/tensorflow,Intel-Corporation/tensorflow,ppwwyyxx/tensorflow,paolodedios/tensorflow,xzturn/tensorflow,paolodedios/tensorflow,arborh/tensorflow,freedomtan/tensorflow,Intel-Corporation/tensorflow,sarvex/tensorflow,gunan/tensorflow,Intel-Corporation/tensorflow,tensorflow/tensorflow,sarvex/tensorflow,jhseu/tensorflow,petewarden/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,aam-at/tensorflow,tensorflow/tensorflow,annarev/tensorflow,aldian/tensorflow,aam-at/tensorflow,sarvex/tensorflow,gunan/tensorflow,gunan/tensorflow,aldian/tensorflow,ppwwyyxx/tensorflow,annarev/tensorflow,xzturn/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,frreiss/tensorflow-fred,ppwwyyxx/tensorflow,frreiss/tensorflow-fred,karllessard/tensorflow,tensorflow/tensorflow-pywrap_saved_model,jhseu/tensorflow,Intel-tensorflow/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,cxxgtxy/tensorflow,gautam1858/tensorflow,freedomtan/tensorflow,Intel-tensorflow/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,tensorflow/tensorflow-pywrap_saved_model,paolodedios/tensorflow,davidzchen/tensorflow,jhseu/tensorflow,renyi533/tensorflow,ppwwyyxx/tensorflow,xzturn/tensorflow,DavidNorman/tensorflow,ppwwyyxx/tensorflow,ppwwyyxx/tensorflow,tensorflow/tensorflow-pywrap_saved_model,aldian/tensorflow,karllessard/tensorflow,paolodedios/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,annarev/tensorflow,annarev/tensorflow,cxxgtxy/tensorflow,Intel-Corporation/tensorflow,davidzchen/tensorflow,tensorflow/tensorflow,annarev/tensorflow,gunan/tensorflow