NumPy allowed · plain Python earns 10 bonus points
Transform unnormalized log-odds (logits) into a valid probability distribution without floating point overflow.
Implement softmax_stable(logits): for each row z in logits, compute exp(z_i - max(z)) / sum(exp(z_j - max(z))). Subtracting the row maximum ensures that the largest exponent evaluated is exp(0) = 1, preventing float overflow. Round every output probability to 4 decimal places.
softmax_stable(logits: list[list[float]]) -> list[list[float]]