Implement Temperature Scaling from “On Calibration of Modern Neural Networks” (Guo et al., 2017).
Temperature scaling is a simple post-hoc calibration method. It divides logits by a learned temperature T before applying softmax:
$$\hat{q}_i = \text{softmax}(z_i / T)$$
Input:
logits: shape (batch, n_classes) — raw model outputs temperature: float T > 0
Output: Tensor of shape (batch, n_classes) — calibrated probabilities.