Change `hasattr` in `Graph.get_collection()` to use try/except.
Change `hasattr` in `Graph.get_collection()` to use try/except.

The current implementation of `hasattr` in Python 2.7 and 3.6 calls `getattr` under the hood. Since we subsequently make a second call to get the attribute, it is more efficient to "ask for forgiveness than permission" in this case.

PiperOrigin-RevId: 264855401

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