"ValueError: Cannot take the length of shape with unknown rank."  when using MultiHeadRelativeAttention
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/61372">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/61372">No</a>

### Issue type

Bug

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

Yes

### Source

source

### TensorFlow version

2.13.1

### Custom code

Yes

### OS platform and distribution

mac M2 pro

### Mobile device

mac M2 pro

### Python version

3.10.9

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

when using MultiHeadRelativeAttention from official.nlp.modeling.layers, I face on this error, "ValueError: Cannot take the length of shape with unknown rank."  I'm sorry  I'm not good at English. Thank you!


### Standalone code to reproduce the issue

```shell
from official.nlp.modeling.layers import MultiHeadRelativeAttention
import tensorflow as tf
vec= tf.constant([[[[0.1]*4]*3]*3])
layers=MultiHeadRelativeAttention(num_heads=4,key_dim=3)
output=layers(vec,vec,content_attention_bias=0.1, positional_attention_bias=0.1)
```


### Relevant log output

```shell
ValueError: Cannot take the length of shape with unknown rank.
```
