Implement cross_entropy(logits, targets) returning (loss, dlogits):
logits: shape (n, C)targets: integer class indices, shape (n,)loss: the mean negative log-likelihood (a Python float)dlogits: gradient of the mean loss w.r.t. logits, shape (n, C)The beautiful result: .
Use log-sum-exp for numerical stability.