src/transformers/pipelines/image_classification.py/ImageClassificationPipeline/postprocess
class ImageClassificationPipeline:    def postprocess(self, model_outputs, top_k=5):
        if top_k > self.model.config.num_labels:
            top_k = self.model.config.num_labels
        probs = model_outputs.logits.softmax(-1)[0]
        scores, ids = probs.topk(top_k)

        scores = scores.tolist()
        ids = ids.tolist()
        return [{"score": score, "label": self.model.config.id2label[_id]} for score, _id in zip(scores, ids)]