Tesla Autopilot's CNN classifier produces one logit vector per camera image. Implement softmax_classify to convert each vector into probabilities and return its top k classes.
Given logits, a nonempty batch represented as a list of lists of real numbers, top_k, and a positive temperature, compute for every sample and class j:
p[j] = exp((logit[j] - max_logit) / temperature) / sum(exp((logit[i] - max_logit) / temperature))
Return one list per sample. Each result must contain exactly top_k entries ordered by decreasing probability. Represent each entry as [class_index, probability], where probabilities are rounded to six decimal places. If probabilities tie, order the smaller class index first. The class index is the position in that sample's logit vector.
Subtracting the maximum logit is required for numerical stability, but must not change the mathematical probabilities.
def softmax_classify(logits, top_k, temperature):