docstr: The output of a networks prediction (PredictionProto) with additional information
  
  It stores all required information for decoding (`codec`) and interpreting the output.
  
  Parameters
  ----------
  prediction : PredictionProto
      prediction the DNN
  codec : Codec
      codec required to decode the `prediction`
  text_postproc : TextPostprocessor
      text processor to apply to the decodec `prediction` to receive the actual prediction sentence
docstr_tok: ["The","output","of","a","networks","prediction","(","PredictionProto",")","with","additional","information","It","stores","all","required","information","for","decoding","(","`","codec","`",")","and","interpreting","the","output",".","Parameters","--","--","--","--","--","prediction",":","PredictionProto","prediction","the","DNN","codec",":","Codec","codec","required","to","decode","the","`","prediction","`","text_postproc",":","TextPostprocessor","text","processor","to","apply","to","the","decodec","`","prediction","`","to","receive","the","actual","prediction","sentence"]
code: def __init__(
      self,
      prediction,
      codec,
      text_postproc,
      out_to_in_trans: Callable[[int], int],
      ground_truth=None,
  ):
      """The output of a networks prediction (PredictionProto) with additional information
  
      It stores all required information for decoding (`codec`) and interpreting the output.
  
      Parameters
      ----------
      prediction : PredictionProto
          prediction the DNN
      codec : Codec
          codec required to decode the `prediction`
      text_postproc : TextPostprocessor
          text processor to apply to the decodec `prediction` to receive the actual prediction sentence
      """
      self.prediction = prediction
      self.logits = prediction.logits
      self.codec = codec
      self.text_postproc = text_postproc
      self.chars = codec.decode(prediction.labels)
      self.sentence = self.text_postproc.apply_on_sample(
          Sample(inputs="", outputs="".join(self.chars))
      ).outputs
      self.prediction.sentence = self.sentence
      self.out_to_in_trans = out_to_in_trans
      self.ground_truth = ground_truth
  
      self.prediction.avg_char_probability = 0
  
      for p in self.prediction.positions:
          for c in p.chars:
              c.char = codec.code2char[c.label]
  
          p.global_start = int(self.out_to_in_trans(p.local_start))
          p.global_end = int(self.out_to_in_trans(p.local_end))
          if len(p.chars) > 0:
              self.prediction.avg_char_probability += p.chars[
                  0
              ].probability
  
      self.prediction.avg_char_probability /= (
          len(self.prediction.positions)
          if len(self.prediction.positions) > 0
          else 1
      )
  
file_path: calamari/calamari_ocr/ocr/predict/params.py
imports: from dataclasses import dataclass, field
  from typing import Callable, List, Optional
  import numpy
  import tfaip
  from dataclasses_json import dataclass_json
  from paiargparse import pai_meta
  from tfaip.data.pipeline.definitions import Sample
label_desc: Use image node_id 1 to create a new PredictionResult object  with example: obj = PredictionResult(prediction, codec, text_postproc, out_to_in_trans, ground_truth)