Improve error message when function local variables are GC'd.
Improve error message when function local variables are GC'd.

New message:

```
ValueError: A tf.Variable created inside your tf.function has been garbage-collected. Your code needs to keep Python references to variables created inside `tf.function`s.

A common way to raise this error is to create and return a variable only referenced inside your function:

@tf.function
def f():
  v = tf.Variable(1.0)
  return v

v = f()  # Crashes with this error message!

The reason this crashes is that @tf.function annotated function returns a **`tf.Tensor`** with the **value** of the variable when the function is called rather than the variable instance itself. As such there is no code holding a reference to the `v` created inside the function and Python garbage collects it.

The simplest way to fix this issue is to create variables outside the function and capture them:

v = tf.Variable(1.0)

@tf.function
def f():
  return v

f()  # <tf.Tensor: ... numpy=1.>
v.assign_add(1.)
f()  # <tf.Tensor: ... numpy=2.>
```

PiperOrigin-RevId: 225957777

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