tf.raw_ops.DatasetToTFRecord: Aborted (core dumped)
@SuryanarayanaY I was able to replicate the issue [here](https://colab.research.google.com/gist/sushreebarsa/4b75f733badae5b6a8292c394399464b/63689.ipynb). Thank you!
### Issue type

Bug

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

Yes

### Source

binary

### TensorFlow version

tf 2.15

### Custom code

Yes

### OS platform and distribution

Ubuntu 20.04

### Mobile device

_No response_

### Python version

3.9

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

Under specific input, `tf.raw_ops.DatasetToTFRecord` encounters "Aborted (core dumped)".

### Standalone code to reproduce the issue

```shell
import tensorflow as tf

input_data = [[1, 2], [3, 4], [5, 6]]

input_data_strings = [[str(d) for d in inner_list] for inner_list in input_data]

dataset = tf.data.Dataset.from_tensor_slices(input_data_strings)

filename = "output.tfrecord"

tf.raw_ops.DatasetToTFRecord(input_dataset=dataset._variant_tensor, filename=filename, compression_type="")
```


### Relevant log output

```shell
2024-03-14 05:41:32.476705: F tensorflow/core/framework/tensor.cc:852] Check failed: 1 == NumElements() (1 vs. 2)Must have a one element tensor
Aborted (core dumped)
```
