// SPDX-License-Identifier: Apache-2.0 OR MIT
//! Loss functions.
use crateTensor;
/// Mean squared error loss: `sum((pred - target)^2) / N`.
///
/// Returns a scalar tensor (shape `[1]`). Only `pred` receives a
/// gradient; `target` is treated as a constant.
/// Cross-entropy loss with Log-Sum-Exp numerical stability.
///
/// `logits`: `[B, C]` — raw unnormalized scores.
/// `targets`: `[B]` — integer class indices (stored as f32).
///
/// Returns a scalar tensor (shape `[1]`). The gradient (softmax - one_hot,
/// scaled by 1/B) is pre-computed during the forward pass for efficiency.