NumPy allowed · plain Python earns 10 bonus points
Compute the softmax backpropagation gradient efficiently in O(n) time without constructing the full n x n Jacobian matrix.
Implement softmax_gradient(s, grad_output). Given softmax probabilities s and upstream gradient g, compute the vector-Jacobian product: (J^T g)_i = s_i * (g_i - sum_j s_j * g_j) in O(n) time.
softmax_gradient(s: list[float], grad_output: list[float]) -> list[float]