pub fn clip_gradient(grad: &mut [f64], max_norm: f64)
Clips the L2 norm of grad to max_norm (in-place).
grad
max_norm
Used in deep learning / physics-ML to stabilise training.