quantize_and_dequantize_v2 crashes when computing gradients in forward mode
assign this to me
i have a working solution in mind Based on the error message, it appears that the issue is with the _QuantizeAndDequantizeV4GradGrad() function in TensorFlow's backend. One possible workaround is to use a custom gradient for the quantize_and_dequantize_v2 function. 

below is code with the custom gradient implementation:

import tensorflow as tf
import numpy as np

tensor = tf.random.normal(shape=[1, 1], mean=127, stddev=50, dtype=tf.float32)

@tf.custom_gradient
def func(tensor):
    quanti = tf.quantization.quantize_and_dequantize_v2(tensor, 
                                                        input_min = 0.0,
                                                        input_max = 255.0,
                                                        num_bits = 8,
                                                        range_given=False)
    
    def grad(dy):
        return dy
    return quanti, grad

output = func(tensor) # pass
with tf.autodiff.ForwardAccumulator(tensor, tf.constant([[0.], [1.]])) as acc:
    output = func(tensor)

Here, we've wrapped the quantize_and_dequantize_v2 call inside a @tf.custom_gradient decorator. This allows us to define a custom gradient function that overrides the default gradient implementation.

In this case, we've defined the gradient function as def grad(dy): return dy, which simply returns the incoming gradient dy unchanged. This is the identity gradient, which is appropriate for this operation because it doesn't modify the input tensor in any way.

With this change, the code should now run without errors. @CrazyShenanigan Thank you for your response here. 
@trickiwoo Thank you for raising this issue! Could you please refer to the comment above and let us know if that helped?

  @sushreebarsa  @CrazyShenanigan Sorry for the delay. Thanks for providing the workaround for the issue! I tried implementing the workaround you suggested, but it doesn't seem to resolve the problem. It fails in gradient computation with the same error message:
```
TypeError: in user code:
    TypeError: _QuantizeAndDequantizeV4GradGrad() takes 2 positional arguments but 4 were given
``` Hi @trickiwoo ,

It seems you are not using the API correct way. I am not sure why you are calling `tf.quantization.quantize_and_dequantize_v2` under the accumulator `tf.autodiff.ForwardAccumulator`. 

The API `tf.autodiff.ForwardAccumulator` expects `loss` function to be defined under this context like we do under GradientTape class and then the method `.jvp(loss)` shall be called to compute JVPs.

I have rewritten the code that the API `tf.autodiff.ForwardAccumulator` expects and it throws no error and JVPs are None as there is no connection between the `primals` and the Tensor returned by `quantize_and_dequantize_v2`.

Please refer to attached [gist](https://colab.research.google.com/gist/SuryanarayanaY/ad96bef34d45bc2a8e95c0fa84069ee2/59960.ipynb). Hi @SuryanarayanaY , thanks for taking a look into it!

I followed the example in the [documentation](https://www.tensorflow.org/api_docs/python/tf/autodiff/ForwardAccumulator), where it also calls the function within the scope of `tf.autodiff.ForwardAccumulator`.
<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Bug

### Have you reproduced the bug with TF nightly?

Yes

### Source

source

### Tensorflow Version

2.11

### Custom Code

Yes

### OS Platform and Distribution

_No response_

### Mobile device

_No response_

### Python version

_No response_

### Bazel version

_No response_

### GCC/Compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current Behaviour?

```shell
quantize_and_dequantize_v2 crashes when computing gradients in forward mode. According to the error message, `quantize_and_dequantize_v2` seems to link with the wrong version of the operator.
```


### Standalone code to reproduce the issue

```shell
import tensorflow as tf
import numpy as np

tensor = tf.random.normal(shape=[1, 1], mean=127, stddev=50, dtype=tf.float32)

def func(tensor):
    quanti = tf.quantization.quantize_and_dequantize_v2(tensor, 
                                                        input_min = 0.0,
                                                        input_max = 255.0,
                                                        num_bits = 8,
                                                        range_given=False)
    
    return quanti

output = func(tensor) # pass
with tf.autodiff.ForwardAccumulator(tensor, tf.constant([[0.], [1.]])) as acc:
    output = func(tensor)
```


### Relevant log output

```shell
TypeError: _QuantizeAndDequantizeV4GradGrad() takes 2 positional arguments but 4 were given
```
</details>