Inconsistencies in Results for `tf.keras.metrics` and `tf.keras.losses`
Hi **@markub3327** ,
I was able to reproduce the issue on Colab using TF v2.15 and nightly. Please find the [gist](https://colab.sandbox.google.com/gist/Venkat6871/8d77ba53d1a1663516393435c04959c3/62767_2-15-_nighlty-v.ipynb) for your reference.

Thank you!
### Issue type

Bug

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

Yes

### Source

binary

### TensorFlow version

2.15

### Custom code

Yes

### OS platform and distribution

Ubuntu 22.04

### Mobile device

Ubuntu 22.04

### Python version

3.9.10

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

The current behavior highlights an inconsistency between the outcomes obtained using `tf.keras.metrics.LogCoshError()` and `tf.keras.losses.LogCosh()`. The discrepancy arises when utilizing the `sample_weight=weights` argument. The objective is to compute a weighted mean during both the training and testing phases.

### Standalone code to reproduce the issue

```shell
true_values = tf.constant([[3.5, 8.2], [1.8, 6.7]])
predicted_values = tf.constant([[5.1, 7.9], [10.4, 3.2]])
weights = tf.constant([0.9, 0.4])

logcosh_metric = tf.keras.metrics.LogCoshError()
logcosh_metric.update_state(true_values, predicted_values)
print("LogCosh without weights:", logcosh_metric.result().numpy())

logcosh_metric = tf.keras.metrics.LogCoshError()
logcosh_metric.update_state(true_values, predicted_values, sample_weight=weights)
print("LogCosh with weights:", logcosh_metric.result().numpy())

true_labels = tf.constant([[3.5, 8.2], [1.8, 6.7]])
predicted_labels = tf.constant([[5.1, 7.9], [10.4, 3.2]])
weights = tf.constant([0.9, 0.4])

logcosh_loss = tf.keras.losses.LogCosh()

print("LogCosh without weights:", logcosh_loss(true_labels, predicted_labels).numpy())
print("LogCosh with weights:", logcosh_loss(true_labels, predicted_labels, sample_weight=weights).numpy())
```


### Relevant log output

```shell
<tf.Variable 'UnreadVariable' shape=() dtype=float32, numpy=2.0>
LogCosh without weights: 2.926441

<tf.Variable 'UnreadVariable' shape=() dtype=float32, numpy=1.3>
LogCosh with weights: 1.9914919

LogCosh without weights: 2.926441
LogCosh with weights: 1.2944697
```
