code: def map_class_to_label(probs, mapping=None, lbl_classes=None):
      """
      Given a list of classes & probabilities, return a dictionary of
      { friendly class name -> probability }
      """
      if not (isinstance(probs, list) and isinstance(probs, list)):
          raise Exception(
              "Convert classes to list before doing mapping"
          )
      if mapping is not None and not isinstance(mapping, dict):
          raise Exception("Mapping must be a dict")
  
      if lbl_classes is None:
          lbl_classes = itertools.repeat(
              range(len(probs[0])), len(probs)
          )
  
      results = [
          {
              (
                  mapping[str(lbl_class)]
                  if mapping is not None
                  else str(lbl_class)
              ): prob
              for lbl_class, prob in zip(*row)
          }
          for row in zip(lbl_classes, probs)
      ]
  
      return results
  
file_path: serve/frontend/server/src/test/resources/densenet_workflow_handler.py
imports: import io
  import logging
  import os
  from PIL import Image
  import torch.nn.functional
  import torch
  import itertools
  import json
  from torchvision import transforms
label_desc: Use image node_id 4 for calling a global function with example usage: map_class_to_label(probs, mapping, lbl_classes) and returns: results