def _aggregate_additional_loss(self, loss):
        """Aggregates losses from `add_loss`, regularizers and sublayers.

        Args:
            loss: A tensor representing the additional loss to aggregate.

        Returns:
            A tensor representing the summed loss, cast to the `floatx()` if
            necessary.
        """
        if not backend.is_float_dtype(loss.dtype):
            loss = ops.cast(loss, dtype=backend.floatx())
        return ops.sum(loss)
Aggregates losses from `add_loss`, regularizers and sublayers.

        Args:
            loss: A tensor representing the additional loss to aggregate.

        Returns:
            A tensor representing the summed loss, cast to the `floatx()` if
            necessary.
        
keras/src/trainers/trainer.py