AddN cannot handle shapes [x,y] + [1,y] or [x,1]
@josh0-jrg,
Thank you for reporting the issue. We are currently investigating the issue, and I kindly request some time to thoroughly analyze the problem in order to offer a resolution. Thank you! Directly from the [documentation](https://www.tensorflow.org/api_docs/python/tf/math/add_n):
> All inputs in the list must have the same shape. This op does not [broadcast](https://docs.scipy.org/doc/numpy-1.13.0/user/basics.broadcasting.html) its inputs. If you need broadcasting, use [tf.math.add](https://www.tensorflow.org/api_docs/python/tf/math/add) (or the + operator) instead.

You can explicitly broadcast your inputs using something like `tf.broadcast_to`. @josh0-jrg , 

As per the above suggestion, you can explicitly broadcast values to certain shape and try the operation.
Below is the code and the output.

```python
import tensorflow as tf
o=tf.newaxis

nel=tf.range(1,10,1,tf.float32)
nph=tf.range(5,15,1,tf.float32)
nel_2D=tf.repeat(nel[:,o],tf.shape(nph)[0],axis=1)

@tf.function
def add_N(x,y):
 return tf.add_n([x,y])
@tf.function
def add_v2(x,y):
 return x+y

tf.print('Shapes:\nX= ',tf.shape(nel_2D), '\nY[o,:] = ',tf.shape(nph[o,:]))

broadcast = tf.broadcast_to(nph[o,:], [9,10])
tf.print('X + Y ',tf.shape(add_v2(nel_2D,nph[o,:])))

tf.print(' tf.add_n([x,y]) fails!')

add_N(nel_2D,broadcast)
```

<details><summary> Output:</summary>

```
Shapes:
X=  [9 10] 
Y[o,:] =  [1 10]
X + Y  [9 10]
 tf.add_n([x,y]) fails!
<tf.Tensor: shape=(9, 10), dtype=float32, numpy=
array([[ 6.,  7.,  8.,  9., 10., 11., 12., 13., 14., 15.],
       [ 7.,  8.,  9., 10., 11., 12., 13., 14., 15., 16.],
       [ 8.,  9., 10., 11., 12., 13., 14., 15., 16., 17.],
       [ 9., 10., 11., 12., 13., 14., 15., 16., 17., 18.],
       [10., 11., 12., 13., 14., 15., 16., 17., 18., 19.],
       [11., 12., 13., 14., 15., 16., 17., 18., 19., 20.],
       [12., 13., 14., 15., 16., 17., 18., 19., 20., 21.],
       [13., 14., 15., 16., 17., 18., 19., 20., 21., 22.],
       [14., 15., 16., 17., 18., 19., 20., 21., 22., 23.]], dtype=float32)>
```
</details> This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. 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/62187">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/62187">No</a>

### Issue type

Bug

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

Yes

### Source

source

### TensorFlow version

2.13.0

### Custom code

Yes

### OS platform and distribution

Windows 11, CentOs8, Ubuntu

### 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?

I found this behaviour when calculating hessians of my custom TensorFlow function. For performance, I manipulate some tensors with unique and gather. This pops up for hessians only so I can't think of how to manipulate my code to avoid AddN. 

Surely, AddN should support the same operations as Add?


Output:
`2.13.0 **Also repeated in 2.16.0-dev20231020**
Shapes:
X=  [9 10] 
Y[o,:] =  [1 10]
X + Y  [9 10]
 tf.add_n([x,y]) fails!

    ValueError: Dimension 0 in both shapes must be equal, but are 9 and 1. Shapes are [9,10] and [1,10].
    	From merging shape 0 with other shapes. for '{{node AddN}} = AddN[N=2, T=DT_FLOAT](x, y)' with input shapes: [9,10], [1,10].`

### Standalone code to reproduce the issue

```shell
import tensorflow as tf
o=tf.newaxis

nel=tf.range(1,10,1,tf.float32)
nph=tf.range(5,15,1,tf.float32)
nel_2D=tf.repeat(nel[:,o],tf.shape(nph)[0],axis=1)

@tf.function
def add_N(x,y):
 return tf.add_n([x,y])
@tf.function
def add_v2(x,y):
 return x+y

tf.print('Shapes:\nX= ',tf.shape(nel_2D), '\nY[o,:] = ',tf.shape(nph[o,:]))


tf.print('X + Y ',tf.shape(add_v2(nel_2D,nph[o,:])))

tf.print(' tf.add_n([x,y]) fails!')

add_N(nel_2D,nph[o,:])
```


### Relevant log output

_No response_