Add a try/finally to context managers.
Add a try/finally to context managers.

This way the state is always reset if an error occurs after the context manager yields.

PiperOrigin-RevId: 194228925

xodus7/tensorflow,adit-chandra/tensorflow,tensorflow/tensorflow-pywrap_saved_model,davidzchen/tensorflow,ageron/tensorflow,gojira/tensorflow,aselle/tensorflow,dongjoon-hyun/tensorflow,AnishShah/tensorflow,gunan/tensorflow,gunan/tensorflow,paolodedios/tensorflow,jalexvig/tensorflow,davidzchen/tensorflow,dongjoon-hyun/tensorflow,ageron/tensorflow,aldian/tensorflow,benoitsteiner/tensorflow-xsmm,theflofly/tensorflow,dancingdan/tensorflow,gautam1858/tensorflow,jendap/tensorflow,dongjoon-hyun/tensorflow,benoitsteiner/tensorflow-xsmm,aam-at/tensorflow,aselle/tensorflow,karllessard/tensorflow,chemelnucfin/tensorflow,caisq/tensorflow,aam-at/tensorflow,jalexvig/tensorflow,aselle/tensorflow,ageron/tensorflow,drpngx/tensorflow,hfp/tensorflow-xsmm,ghchinoy/tensorflow,manipopopo/tensorflow,snnn/tensorflow,gojira/tensorflow,chemelnucfin/tensorflow,caisq/tensorflow,brchiu/tensorflow,tensorflow/tensorflow,adit-chandra/tensorflow,gunan/tensorflow,ghchinoy/tensorflow,alsrgv/tensorflow,jhseu/tensorflow,davidzchen/tensorflow,arborh/tensorflow,ppwwyyxx/tensorflow,Intel-Corporation/tensorflow,gojira/tensorflow,tensorflow/tensorflow-pywrap_saved_model,jbedorf/tensorflow,gunan/tensorflow,ppwwyyxx/tensorflow,benoitsteiner/tensorflow-xsmm,tensorflow/tensorflow-experimental_link_static_libraries_once,DavidNorman/tensorflow,Intel-tensorflow/tensorflow,DavidNorman/tensorflow,yongtang/tensorflow,ghchinoy/tensorflow,AnishShah/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,jbedorf/tensorflow,frreiss/tensorflow-fred,hehongliang/tensorflow,frreiss/tensorflow-fred,xzturn/tensorflow,aselle/tensorflow,petewarden/tensorflow,Intel-Corporation/tensorflow,ZhangXinNan/tensorflow,aselle/tensorflow,sarvex/tensorflow,annarev/tensorflow,jendap/tensorflow,adit-chandra/tensorflow,frreiss/tensorflow-fred,tensorflow/tensorflow-pywrap_tf_optimizer,ageron/tensorflow,jendap/tensorflow,kobejean/tensorflow,DavidNorman/tensorflow,kobejean/tensorflow,lukeiwanski/tensorflow,petewarden/tensorflow,ZhangXinNan/tensorflow,ZhangXinNan/tensorflow,petewarden/tensorflow,gautam1858/tensorflow,hehongliang/tensorflow,sarvex/tensorflow,dongjoon-hyun/tensorflow,hfp/tensorflow-xsmm,manipopopo/tensorflow,hfp/tensorflow-xsmm,kobejean/tensorflow,dancingdan/tensorflow,karllessard/tensorflow,lukeiwanski/tensorflow,kevin-coder/tensorflow-fork,lukeiwanski/tensorflow,asimshankar/tensorflow,arborh/tensorflow,gojira/tensorflow,caisq/tensorflow,AnishShah/tensorflow,jbedorf/tensorflow,chemelnucfin/tensorflow,arborh/tensorflow,kevin-coder/tensorflow-fork,gojira/tensorflow,AnishShah/tensorflow,girving/tensorflow,Intel-tensorflow/tensorflow,yongtang/tensorflow,theflofly/tensorflow,gunan/tensorflow,kevin-coder/tensorflow-fork,tensorflow/tensorflow-pywrap_saved_model,chemelnucfin/tensorflow,chemelnucfin/tensorflow,freedomtan/tensorflow,xzturn/tensorflow,xzturn/tensorflow,davidzchen/tensorflow,aam-at/tensorflow,manipopopo/tensorflow,ZhangXinNan/tensorflow,drpngx/tensorflow,renyi533/tensorflow,dongjoon-hyun/tensorflow,Bismarrck/tensorflow,aselle/tensorflow,ZhangXinNan/tensorflow,jbedorf/tensorflow,gojira/tensorflow,alshedivat/tensorflow,jart/tensorflow,petewarden/tensorflow,theflofly/tensorflow,Intel-tensorflow/tensorflow,annarev/tensorflow,gautam1858/tensorflow,renyi533/tensorflow,asimshankar/tensorflow,freedomtan/tensorflow,seanli9jan/tensorflow,girving/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,davidzchen/tensorflow,alshedivat/tensorflow,benoitsteiner/tensorflow-xsmm,sarvex/tensorflow,Intel-tensorflow/tensorflow,girving/tensorflow,petewarden/tensorflow,davidzchen/tensorflow,DavidNorman/tensorflow,xodus7/tensorflow,snnn/tensorflow,annarev/tensorflow,aselle/tensorflow,ppwwyyxx/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,drpngx/tensorflow,alsrgv/tensorflow,adit-chandra/tensorflow,dongjoon-hyun/tensorflow,lukeiwanski/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,jendap/tensorflow,nburn42/tensorflow,gojira/tensorflow,renyi533/tensorflow,theflofly/tensorflow,benoitsteiner/tensorflow-xsmm,xodus7/tensorflow,ppwwyyxx/tensorflow,ppwwyyxx/tensorflow,meteorcloudy/tensorflow,caisq/tensorflow,lukeiwanski/tensorflow,aldian/tensorflow,girving/tensorflow,tensorflow/tensorflow,chemelnucfin/tensorflow,theflofly/tensorflow,meteorcloudy/tensorflow,cxxgtxy/tensorflow,frreiss/tensorflow-fred,jart/tensorflow,meteorcloudy/tensorflow,freedomtan/tensorflow,alshedivat/tensorflow,adit-chandra/tensorflow,dancingdan/tensorflow,aselle/tensorflow,tensorflow/tensorflow-pywrap_saved_model,AnishShah/tensorflow,xodus7/tensorflow,apark263/tensorflow,petewarden/tensorflow,girving/tensorflow,kevin-coder/tensorflow-fork,alshedivat/tensorflow,frreiss/tensorflow-fred,ZhangXinNan/tensorflow,frreiss/tensorflow-fred,apark263/tensorflow,annarev/tensorflow,yanchen036/tensorflow,kevin-coder/tensorflow-fork,karllessard/tensorflow,jart/tensorflow,jhseu/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,snnn/tensorflow,ageron/tensorflow,aam-at/tensorflow,cxxgtxy/tensorflow,tensorflow/tensorflow-pywrap_saved_model,chemelnucfin/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,hfp/tensorflow-xsmm,nburn42/tensorflow,tensorflow/tensorflow-pywrap_saved_model,apark263/tensorflow,karllessard/tensorflow,gojira/tensorflow,AnishShah/tensorflow,aldian/tensorflow,nburn42/tensorflow,apark263/tensorflow,lukeiwanski/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,ageron/tensorflow,apark263/tensorflow,dendisuhubdy/tensorflow,jbedorf/tensorflow,ghchinoy/tensorflow,aam-at/tensorflow,cxxgtxy/tensorflow,gunan/tensorflow,Bismarrck/tensorflow,xodus7/tensorflow,snnn/tensorflow,asimshankar/tensorflow,chemelnucfin/tensorflow,gojira/tensorflow,freedomtan/tensorflow,tensorflow/tensorflow,yongtang/tensorflow,cxxgtxy/tensorflow,DavidNorman/tensorflow,kobejean/tensorflow,xzturn/tensorflow,brchiu/tensorflow,adit-chandra/tensorflow,caisq/tensorflow,meteorcloudy/tensorflow,jhseu/tensorflow,arborh/tensorflow,apark263/tensorflow,jalexvig/tensorflow,jart/tensorflow,annarev/tensorflow,ppwwyyxx/tensorflow,aselle/tensorflow,gautam1858/tensorflow,dancingdan/tensorflow,tensorflow/tensorflow,brchiu/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,frreiss/tensorflow-fred,nburn42/tensorflow,Intel-tensorflow/tensorflow,hfp/tensorflow-xsmm,yongtang/tensorflow,xodus7/tensorflow,brchiu/tensorflow,jhseu/tensorflow,kobejean/tensorflow,alsrgv/tensorflow,jbedorf/tensorflow,renyi533/tensorflow,renyi533/tensorflow,chemelnucfin/tensorflow,ppwwyyxx/tensorflow,xzturn/tensorflow,aldian/tensorflow,yongtang/tensorflow,alsrgv/tensorflow,Bismarrck/tensorflow,yongtang/tensorflow,alsrgv/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,jbedorf/tensorflow,gautam1858/tensorflow,ghchinoy/tensorflow,jalexvig/tensorflow,ppwwyyxx/tensorflow,arborh/tensorflow,yanchen036/tensorflow,kobejean/tensorflow,yongtang/tensorflow,DavidNorman/tensorflow,apark263/tensorflow,dendisuhubdy/tensorflow,girving/tensorflow,Intel-Corporation/tensorflow,gunan/tensorflow,kobejean/tensorflow,xzturn/tensorflow,Intel-tensorflow/tensorflow,ppwwyyxx/tensorflow,ageron/tensorflow,adit-chandra/tensorflow,DavidNorman/tensorflow,Intel-Corporation/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,jendap/tensorflow,DavidNorman/tensorflow,DavidNorman/tensorflow,hfp/tensorflow-xsmm,freedomtan/tensorflow,xodus7/tensorflow,manipopopo/tensorflow,hfp/tensorflow-xsmm,asimshankar/tensorflow,sarvex/tensorflow,tensorflow/tensorflow,asimshankar/tensorflow,karllessard/tensorflow,ppwwyyxx/tensorflow,paolodedios/tensorflow,paolodedios/tensorflow,adit-chandra/tensorflow,hfp/tensorflow-xsmm,dendisuhubdy/tensorflow,meteorcloudy/tensorflow,aldian/tensorflow,benoitsteiner/tensorflow-xsmm,tensorflow/tensorflow-pywrap_tf_optimizer,meteorcloudy/tensorflow,manipopopo/tensorflow,xzturn/tensorflow,arborh/tensorflow,annarev/tensorflow,yongtang/tensorflow,renyi533/tensorflow,freedomtan/tensorflow,chemelnucfin/tensorflow,tensorflow/tensorflow-pywrap_saved_model,dancingdan/tensorflow,kobejean/tensorflow,annarev/tensorflow,kevin-coder/tensorflow-fork,jhseu/tensorflow,dongjoon-hyun/tensorflow,asimshankar/tensorflow,ghchinoy/tensorflow,freedomtan/tensorflow,paolodedios/tensorflow,apark263/tensorflow,DavidNorman/tensorflow,alsrgv/tensorflow,freedomtan/tensorflow,theflofly/tensorflow,kevin-coder/tensorflow-fork,dendisuhubdy/tensorflow,xodus7/tensorflow,nburn42/tensorflow,nburn42/tensorflow,jart/tensorflow,jhseu/tensorflow,ageron/tensorflow,jhseu/tensorflow,dendisuhubdy/tensorflow,xodus7/tensorflow,jalexvig/tensorflow,davidzchen/tensorflow,seanli9jan/tensorflow,Intel-Corporation/tensorflow,snnn/tensorflow,jendap/tensorflow,paolodedios/tensorflow,paolodedios/tensorflow,petewarden/tensorflow,sarvex/tensorflow,jbedorf/tensorflow,seanli9jan/tensorflow,theflofly/tensorflow,jhseu/tensorflow,petewarden/tensorflow,dendisuhubdy/tensorflow,Bismarrck/tensorflow,ageron/tensorflow,karllessard/tensorflow,drpngx/tensorflow,nburn42/tensorflow,manipopopo/tensorflow,snnn/tensorflow,ZhangXinNan/tensorflow,frreiss/tensorflow-fred,benoitsteiner/tensorflow-xsmm,Bismarrck/tensorflow,snnn/tensorflow,dongjoon-hyun/tensorflow,girving/tensorflow,karllessard/tensorflow,dancingdan/tensorflow,jart/tensorflow,davidzchen/tensorflow,yanchen036/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,gojira/tensorflow,alsrgv/tensorflow,snnn/tensorflow,seanli9jan/tensorflow,paolodedios/tensorflow,arborh/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,gautam1858/tensorflow,Intel-Corporation/tensorflow,Bismarrck/tensorflow,jhseu/tensorflow,drpngx/tensorflow,tensorflow/tensorflow,Intel-tensorflow/tensorflow,jendap/tensorflow,Bismarrck/tensorflow,petewarden/tensorflow,petewarden/tensorflow,Intel-tensorflow/tensorflow,cxxgtxy/tensorflow,caisq/tensorflow,karllessard/tensorflow,ageron/tensorflow,DavidNorman/tensorflow,brchiu/tensorflow,aselle/tensorflow,alshedivat/tensorflow,karllessard/tensorflow,Intel-tensorflow/tensorflow,Bismarrck/tensorflow,drpngx/tensorflow,alsrgv/tensorflow,drpngx/tensorflow,petewarden/tensorflow,lukeiwanski/tensorflow,annarev/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,aldian/tensorflow,ppwwyyxx/tensorflow,benoitsteiner/tensorflow-xsmm,jbedorf/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,Bismarrck/tensorflow,hfp/tensorflow-xsmm,jalexvig/tensorflow,kobejean/tensorflow,freedomtan/tensorflow,hehongliang/tensorflow,frreiss/tensorflow-fred,kevin-coder/tensorflow-fork,dongjoon-hyun/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,dendisuhubdy/tensorflow,dancingdan/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,tensorflow/tensorflow,dendisuhubdy/tensorflow,lukeiwanski/tensorflow,jalexvig/tensorflow,freedomtan/tensorflow,annarev/tensorflow,kevin-coder/tensorflow-fork,gunan/tensorflow,gautam1858/tensorflow,ageron/tensorflow,jendap/tensorflow,Intel-Corporation/tensorflow,brchiu/tensorflow,tensorflow/tensorflow-pywrap_saved_model,asimshankar/tensorflow,asimshankar/tensorflow,xzturn/tensorflow,jhseu/tensorflow,alshedivat/tensorflow,theflofly/tensorflow,dendisuhubdy/tensorflow,benoitsteiner/tensorflow-xsmm,jalexvig/tensorflow,gautam1858/tensorflow,lukeiwanski/tensorflow,gautam1858/tensorflow,adit-chandra/tensorflow,paolodedios/tensorflow,ageron/tensorflow,xzturn/tensorflow,davidzchen/tensorflow,Intel-tensorflow/tensorflow,tensorflow/tensorflow-pywrap_saved_model,seanli9jan/tensorflow,tensorflow/tensorflow,girving/tensorflow,jhseu/tensorflow,aldian/tensorflow,renyi533/tensorflow,karllessard/tensorflow,drpngx/tensorflow,jendap/tensorflow,ghchinoy/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,meteorcloudy/tensorflow,chemelnucfin/tensorflow,manipopopo/tensorflow,ghchinoy/tensorflow,ghchinoy/tensorflow,girving/tensorflow,sarvex/tensorflow,gautam1858/tensorflow,jalexvig/tensorflow,alshedivat/tensorflow,chemelnucfin/tensorflow,drpngx/tensorflow,dongjoon-hyun/tensorflow,theflofly/tensorflow,ZhangXinNan/tensorflow,davidzchen/tensorflow,jendap/tensorflow,aam-at/tensorflow,kobejean/tensorflow,gunan/tensorflow,lukeiwanski/tensorflow,dendisuhubdy/tensorflow,freedomtan/tensorflow,caisq/tensorflow,girving/tensorflow,hehongliang/tensorflow,frreiss/tensorflow-fred,jbedorf/tensorflow,Intel-tensorflow/tensorflow,AnishShah/tensorflow,benoitsteiner/tensorflow-xsmm,alshedivat/tensorflow,renyi533/tensorflow,jart/tensorflow,yongtang/tensorflow,manipopopo/tensorflow,paolodedios/tensorflow,seanli9jan/tensorflow,caisq/tensorflow,gautam1858/tensorflow,benoitsteiner/tensorflow-xsmm,karllessard/tensorflow,paolodedios/tensorflow,AnishShah/tensorflow,dancingdan/tensorflow,gunan/tensorflow,brchiu/tensorflow,hehongliang/tensorflow,tensorflow/tensorflow-pywrap_saved_model,tensorflow/tensorflow-pywrap_saved_model,arborh/tensorflow,jbedorf/tensorflow,ppwwyyxx/tensorflow,tensorflow/tensorflow,cxxgtxy/tensorflow,adit-chandra/tensorflow,renyi533/tensorflow,xzturn/tensorflow,nburn42/tensorflow,alsrgv/tensorflow,arborh/tensorflow,seanli9jan/tensorflow,apark263/tensorflow,jendap/tensorflow,annarev/tensorflow,aam-at/tensorflow,aam-at/tensorflow,gunan/tensorflow,snnn/tensorflow,ghchinoy/tensorflow,sarvex/tensorflow,gojira/tensorflow,gunan/tensorflow,yanchen036/tensorflow,yanchen036/tensorflow,seanli9jan/tensorflow,meteorcloudy/tensorflow,yanchen036/tensorflow,caisq/tensorflow,AnishShah/tensorflow,seanli9jan/tensorflow,DavidNorman/tensorflow,snnn/tensorflow,brchiu/tensorflow,seanli9jan/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,aselle/tensorflow,yongtang/tensorflow,theflofly/tensorflow,frreiss/tensorflow-fred,kevin-coder/tensorflow-fork,hehongliang/tensorflow,gautam1858/tensorflow,kobejean/tensorflow,dongjoon-hyun/tensorflow,xzturn/tensorflow,brchiu/tensorflow,hfp/tensorflow-xsmm,manipopopo/tensorflow,asimshankar/tensorflow,theflofly/tensorflow,ghchinoy/tensorflow,jart/tensorflow,ZhangXinNan/tensorflow,alshedivat/tensorflow,cxxgtxy/tensorflow,annarev/tensorflow,renyi533/tensorflow,kevin-coder/tensorflow-fork,arborh/tensorflow,davidzchen/tensorflow,nburn42/tensorflow,alshedivat/tensorflow,alsrgv/tensorflow,manipopopo/tensorflow,brchiu/tensorflow,frreiss/tensorflow-fred,jart/tensorflow,aam-at/tensorflow,tensorflow/tensorflow,AnishShah/tensorflow,yanchen036/tensorflow,girving/tensorflow,xodus7/tensorflow,nburn42/tensorflow,petewarden/tensorflow,aam-at/tensorflow,jart/tensorflow,apark263/tensorflow,Intel-Corporation/tensorflow,ZhangXinNan/tensorflow,davidzchen/tensorflow,aam-at/tensorflow,jhseu/tensorflow,Bismarrck/tensorflow,adit-chandra/tensorflow,xzturn/tensorflow,asimshankar/tensorflow,renyi533/tensorflow,snnn/tensorflow,AnishShah/tensorflow,yanchen036/tensorflow,ghchinoy/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,renyi533/tensorflow,caisq/tensorflow,theflofly/tensorflow,tensorflow/tensorflow,aam-at/tensorflow,yongtang/tensorflow,dancingdan/tensorflow,adit-chandra/tensorflow,alsrgv/tensorflow,paolodedios/tensorflow,drpngx/tensorflow,dancingdan/tensorflow,arborh/tensorflow,Bismarrck/tensorflow,hehongliang/tensorflow,ZhangXinNan/tensorflow,aldian/tensorflow,meteorcloudy/tensorflow,nburn42/tensorflow,xodus7/tensorflow,jalexvig/tensorflow,freedomtan/tensorflow,hfp/tensorflow-xsmm,brchiu/tensorflow,asimshankar/tensorflow,apark263/tensorflow,alshedivat/tensorflow,manipopopo/tensorflow,alsrgv/tensorflow,arborh/tensorflow,cxxgtxy/tensorflow,meteorcloudy/tensorflow,sarvex/tensorflow,dancingdan/tensorflow,jbedorf/tensorflow,jalexvig/tensorflow,seanli9jan/tensorflow