Convert tf.variable into tf. constant 
@schm0 Directly converting a tf.Variable to a tf.constant in TensorFlow is not possible as tf.Variable is designed to be mutable and track its value through iterations. There are a few ways to achieve this such as below;
1. Access the variable's current value
```
current_value = someTFvariable.read_value()
```
2. Create a constant tensor from the value
```
new_var = tf.constant(current_value)
```

Thank you! Thanks for your answer but this results in:
`TypeError: List of Tensors when single Tensor expected.`
Does it matter that the variable gets assigned with state_ops.assign_add?
I can't find much info about state_ops. @schm0 Could you please let us know the exact TF version you are using? 
In order to expedite the trouble-shooting process, please provide a code snippet to reproduce the issue reported here. Thank you!
 > @schm0 Could you please let us know the exact TF version you are using? In order to expedite the trouble-shooting process, please provide a code snippet to reproduce the issue reported here. Thank you!

I use TensorFlow-DirectML 1.15.8.
It's optimizer class.
The variable gets declared as follows:
```
with tf.device('/CPU:0') :
    with tf.variable_scope(self.name):
        self.iterations = tf.Variable(0, dtype=tf.int64, name='iterations')
```
and in the actual "main" optimizer function:
```
....
updates = []
updates += [ state_ops.assign_add( self.iterations, 1) ]
....
return control_flow_ops.group(*updates, name=self.name+'_updates')
```
So this is a global iteration counter.
I need to calculate an offset from this value which I then can subtract from it.
But because the iterations are counted upwards by 1 the offset changes too.
So I need to create a static/constant value. @schm0 TF v1.15 is an older version which is not actively supported. We request you to kindly upgrade to the latest TF version. Thank you! Well...
Isn't this the lastest version that's supports directml?
So it is not possible to create a constant value from this state_op variable? @schm0 it is not possible to directly create a constant value from a state_op variable like self.iterations in TensorFlow-DirectML 1.15.8. This is because state_ops are designed to modify existing state (tf.Variable) rather than create new constants. You could potentially manipulate the self-iterations tensor using TensorFlow operations, such as slicing or masking, to extract a constant portion as an offset.
Thank you! This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/62958">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/62958">No</a>

### Issue type

Support

### Have you reproduced the bug with TensorFlow Nightly?

No

### Source

source

### TensorFlow version

v1.15.8-1-g3800a8e1cd 1.15.8

### Custom code

Yes

### OS platform and distribution

Windows 10

### Mobile device

_No response_

### Python version

3.7.17

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

Hello!
I'm trying to create "snapshot" (constant) of an iterations counter (tf.variable) like this: 
`new_var = tf.constant(someTFvariable)`

But it results:
`TypeError: Failed to convert object of type <class 'tensorflow.python.ops.variables.RefVariable'> to Tensor. Contents: <tf.Variable 'src_dst_opt/iters:0' shape=() dtype=int64_ref>. Consider casting elements to a supported type.
`
The variable got declared like this:
```
        with tf.device('/CPU:0') :
            with tf.variable_scope(self.name):
                self.iterations = tf.Variable(0, dtype=tf.int64, name='iters')

```
`new_var = tf.constant(tf.cast(someTFvariable, dtype=tf.int64))`
Results in:
`Error: List of Tensors when single Tensor expected`

I guess there is an easy solution to this but I can't figure out.
Thanks.

### Standalone code to reproduce the issue

```shell
N/A
```


### Relevant log output

_No response_