Reported interview periodJul 2026
Masked Cross-Entropy with Label Smoothing
Implement numerically stable cross-entropy for class logits, with optional masking and label smoothing.
Practice focusRequirements and assumptions - logits has shape (N,C) or (N,T,C) ; integer targets and mask match its leading dimensions. - Compute mean negative log probability only over positions where the mask is nonzero; without a mask, include all positions. - Label smoothing uses target distribution (1-epsilon) one hot + epsilon/C . - Use log-sum-exp; do not form unstable exponentials or probabilities unnecessarily. - Validate shapes, target range, 0 <= epsilon < 1 , and define the all-masked result explicitly (raise ValueError ).…