Thread-safety for the TFE tape code.
Thread-safety for the TFE tape code.

In multithreaded python any call to a python API function can release the GIL,
so we should not assume our data structures haven't changed across calls to
the python API.

PiperOrigin-RevId: 182835555

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