Repository: tensorflow
Issue: In tf.data.experimental.enable_debug_mode, tf.data.Dataset.ragged_batch fails with an error
Labels: stat:awaiting tensorflower,type:bug,comp:data,TF 2.12

<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Bug

### Have you reproduced the bug with TF nightly?

Yes

### Source

binary

### Tensorflow Version

TF 2.12.0, TF nightly 2.13.0-dev20230404

### 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?

Consider the following code creating ragged batches using `tf.data.Dataset.ragged_batch`:

```python
data = tf.data.Dataset.from_tensor_slices(tf.ragged.constant([[1, 2], [3]]))
list(data.ragged_batch(2))
```

The above code works fine in normal mode. However, if you enable debug mode using `tf.data.experimental.enable_debug_mode()`, the same code crashes with an error.

### Standalone code to reproduce the issue

I reproduced the error in https://colab.research.google.com/drive/1nf1BHjssx2YhF0ZbbgPg1QSALSS4Z89r?usp=sharing , both for TF 2.12.0 and TF nightly 2.13.0-dev20230404.

The code for triggering the bug is the following:

```python
tf.data.experimental.enable_debug_mode()
data = tf.data.Dataset.from_tensor_slices(tf.ragged.constant([[1, 2], [3]]))
list(data.ragged_batch(2))
```

### Relevant log output

Here is the error printed by TF 2.12.0

```
---------------------------------------------------------------------------

InvalidArgumentError                      Traceback (most recent call last)

<ipython-input-3-34b7e4bb8c4b> in <cell line: 4>()
      2 tf.data.experimental.enable_debug_mode()
      3 data = tf.data.Dataset.from_tensor_slices(tf.ragged.constant([[1, 2], [3]]))
----> 4 list(data.ragged_batch(2))

3 frames

/usr/local/lib/python3.9/dist-packages/tensorflow/python/framework/ops.py in raise_from_not_ok_status(e, name)
   6651 def raise_from_not_ok_status(e, name):
   6652   e.message += (" name: " + str(name if name is not None else ""))
-> 6653   raise core._status_to_exception(e) from None  # pylint: disable=protected-access
   6654 
   6655 

InvalidArgumentError: {{function_node __wrapped__IteratorGetNext_output_types_1_device_/job:localhost/replica:0/task:0/device:CPU:0}} ValueError: Value [1 2] is not convertible to a tensor with dtype <dtype: 'variant'> and shape ().
Traceback (most recent call last):

  File "/usr/local/lib/python3.9/dist-packages/tensorflow/python/data/util/structure.py", line 347, in reduce_fn
    component = ops.convert_to_tensor(component, spec.dtype)

  File "/usr/local/lib/python3.9/dist-packages/tensorflow/python/profiler/trace.py", line 183, in wrapped
    return func(*args, **kwargs)

  File "/usr/local/lib/python3.9/dist-packages/tensorflow/python/framework/ops.py", line 1440, in convert_to_tensor
    return tensor_conversion_registry.convert(

  File "/usr/local/lib/python3.9/dist-packages/tensorflow/python/framework/tensor_conversion_registry.py", line 209, in convert
    return overload(dtype, name)  #  pylint: disable=not-callable

  File "/usr/local/lib/python3.9/dist-packages/tensorflow/python/framework/ops.py", line 1335, in __tf_tensor__
    return super().__tf_tensor__(dtype, name)

  File "/usr/local/lib/python3.9/dist-packages/tensorflow/python/framework/ops.py", line 967, in __tf_tensor__
    raise ValueError(

ValueError: Tensor conversion requested dtype variant for Tensor with dtype int32: <tf.Tensor: shape=(2,), dtype=int32, numpy=array([1, 2], dtype=int32)>


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/usr/local/lib/python3.9/dist-packages/tensorflow/python/ops/script_ops.py", line 266, in __call__
    return func(device, token, args)

  File "/usr/local/lib/python3.9/dist-packages/tensorflow/python/ops/script_ops.py", line 144, in __call__
    outputs = self._call(device, args)

  File "/usr/local/lib/python3.9/dist-packages/tensorflow/python/ops/script_ops.py", line 151, in _call
    ret = self._func(*args)

  File "/usr/local/lib/python3.9/dist-packages/tensorflow/python/autograph/impl/api.py", line 643, in wrapper
    return func(*args, **kwargs)

  File "/usr/local/lib/python3.9/dist-packages/tensorflow/python/data/ops/structured_function.py", line 213, in py_function_wrapper
    ret = structure.to_tensor_list(self._output_structure, ret)

  File "/usr/local/lib/python3.9/dist-packages/tensorflow/python/data/util/structure.py", line 410, in to_tensor_list
    return _to_tensor_list_helper(

  File "/usr/local/lib/python3.9/dist-packages/tensorflow/python/data/util/structure.py", line 360, in _to_tensor_list_helper
    return functools.reduce(

  File "/usr/local/lib/python3.9/dist-packages/tensorflow/python/data/util/structure.py", line 349, in reduce_fn
    raise ValueError(

ValueError: Value [1 2] is not convertible to a tensor with dtype <dtype: 'variant'> and shape ().


	 [[{{node EagerPyFunc}}]] [Op:IteratorGetNext] name:
```
</details>