Aborted (core dumped) in `tf.transpose`
@x0w3n I was able to replicate the issue reported using TF [2.16](https://colab.research.google.com/gist/sushreebarsa/448cdd28d822c0c7ff9f1bd4cadab141/69213-nightly.ipynb) and tf-[nightly](https://colab.research.google.com/gist/sushreebarsa/20944b00e753931560aa668a254b4f30/69213-nightly.ipynb).
Thank you! 

### Issue type

Bug

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

Yes

### Source

source

### TensorFlow version

tf 2.16

### Custom code

Yes

### OS platform and distribution

Linux Ubuntu 22.04.3 LTS (x86_64)

### Mobile device

_No response_

### Python version

3.9.13

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

A crash is triggered when some boundary values are passed to the perm parameter of these transpose functions. the affected APIs are as follows:

1. tf.transpose
2. tf.experimental.numpy.transpose
3. tf.compat.v1.transpose
4. tf.keras.ops.transpose
5. tf.raw_ops.transpose
6. tf.raw_ops.ConjugateTranspose

tf.raw_ops.ConjugateTranspose is a Segmentation fault crash, all other API crashes are Aborted. 

### Standalone code to reproduce the issue

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

x = tf.random.normal(shape=(3, 3))
# crash
x = tf.transpose(x, perm=((- 1), (- 2))) 
 
# crash 
# tf.experimental.numpy.transpose(     
#     x, axes=((- 1), (- 2))
# )

# crash 
# tf.compat.v1.transpose(  
#     x, perm=((- 1), (- 2)), name='transpose', conjugate=False
# )

# crash
# tf.keras.ops.transpose(
#     x, axes=((- 1), (- 2))
# )

# crash
# tf.raw_ops.ConjugateTranspose(
#     x=x, perm=((- 1), (- 2))
# )

# crash
# tf.raw_ops.Transpose(
#     x=x, perm=((- 1), (- 2))
# )
```


### Relevant log output

```shell
2024-06-05 09:16:55.482645: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-06-05 09:16:56.526139: F tensorflow/core/framework/tensor_shape.cc:356] Check failed: d >= 0 (0 vs. -1)
Aborted (core dumped)

2024-06-05 09:17:47.967585: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
Segmentation fault (core dumped)
```
