code: def _get_prediction_from_scores(
      scores: torch.Tensor, classes: List[str]
  ) -> List[List[Dict[str, float]]]:
      """
      Given scores for a batch, get the prediction for each word in the form of a
      List[List[Dict[str, float]]] for callers of the torchscript model to consume.
      The outer list iterates over batches of sentences and the inner iterates
      over each token in the sentence. The dictionary consists of
      `label:score` for each word.
  
      Example:
  
      Assuming slot labels are [No-Label, Number, Name]
      Utterances: [[call john please], [Brightness 25]]
      Output could look like:
      [
          [
              { No-Label: -0.1, Number: -1.5, Name: -9.01},
              { No-Label: -2.1, Number: -1.5, Name: -0.01},
              { No-Label: -0.1, Number: -1.5, Name: -2.01},
          ],
          [
              { No-Label: -0.1, Number: -1.5, Name: -9.01},
              { No-Label: -2.1, Number: -0.5, Name: -7.01},
              { No-Label: -0.1, Number: -1.5, Name: -2.01},
          ]
      ]
      """
      results: List[List[Dict[str, float]]] = []
      # Extra verbosity because jit doesn't support zip
      for sentence_scores in scores.chunk(len(scores)):
          sentence_scores = sentence_scores.squeeze(0)
          sentence_response: List[Dict[str, float]] = []
          for word_scores in sentence_scores.chunk(
              len(sentence_scores)
          ):
              word_scores = word_scores.squeeze(0)
              word_response: Dict[str, float] = {}
              for i in range(len(classes)):
                  word_response[classes[i]] = float(
                      word_scores[i].item()
                  )
              sentence_response.append(word_response)
          results.append(sentence_response)
      return results
  
imports: from typing import Any, Dict, List, Optional, Tuple, Union
  import torch
  import torch.jit
  import torch.nn
  import torch.nn.functional
  from caffe2.python import core
  from pytext.common import Padding
  from pytext.config.component import create_loss
  from pytext.config.serialize import MissingValueError
  from pytext.data.utils import Vocabulary
  from pytext.loss import AUCPRHingeLoss, BinaryCrossEntropyLoss, CrossEntropyLoss, KLDivergenceBCELoss, KLDivergenceCELoss, LabelSmoothedCrossEntropyLoss, StructuredLoss, StructuredMarginLoss
  from pytext.models.crf import CRF
  from pytext.utils.label import get_label_weights
  from pytext.utils.usage import log_class_usage
  from .output_layer_base import OutputLayerBase
  from .utils import OutputLayerUtils
label_desc: Use image node_id 2 for calling a global function with example usage: _get_prediction_from_scores(scores, classes) and returns: results