docstr: Construct a codec based on a given charset (symbols)
  
  A symbol is typically a character (e.g. a, b, c, d, ...) in OCR, in OMR this might be
  the position of a note in the staff.
  The labels are required for training, since the DNN will only predict integer numbers (classes).
  Given a set of symbols the codec will automatically assign a label to each character and store it for
  processing of a line.
  
  The codec then is used to `decode` and `encode` a line.
  
  
  As first index a __blank__ (empty string) will be added as required for the CTC algorithm.
docstr_tok: ["Construct","a","codec","based","on","a","given","charset","(","symbols",")","A","symbol","is","typically","a","character","(","e.g",".","a",",","b",",","c",",","d",",","...",")","in","OCR",",","in","OMR","this","might","be","the","position","of","a","note","in","the","staff",".","The","labels","are","required","for","training",",","since","the","DNN","will","only","predict","integer","numbers","(","classes",")",".","Given","a","set","of","symbols","the","codec","will","automatically","assign","a","label","to","each","character","and","store","it","for","processing","of","a","line",".","The","codec","then","is","used","to","`","decode","`","and","`","encode","`","a","line",".","As","first","index","a","__blank__","(","empty","string",")","will","be","added","as","required","for","the","CTC","algorithm","."]
code: def __post_init__(self):
      """Construct a codec based on a given charset (symbols)
  
      A symbol is typically a character (e.g. a, b, c, d, ...) in OCR, in OMR this might be
      the position of a note in the staff.
      The labels are required for training, since the DNN will only predict integer numbers (classes).
      Given a set of symbols the codec will automatically assign a label to each character and store it for
      processing of a line.
  
      The codec then is used to `decode` and `encode` a line.
  
  
      As first index a __blank__ (empty string) will be added as required for the CTC algorithm.
      """
      charset = list(self.charset)
      if len(charset) == 0:
          raise Exception("Got empty charset")
  
      if charset[0] != "":
          self.charset = [""] + charset  # blank is label 0
      else:
          self.charset = charset
  
      self.code2char = {}
      self.char2code = {}
      for code, char in enumerate(self.charset):
          self.code2char[code] = char
          self.char2code[char] = code
  
file_path: calamari/calamari_ocr/ocr/dataset/codec.py
imports: from dataclasses import dataclass, field
  from typing import List, TYPE_CHECKING, Iterator, Set
  from paiargparse import pai_dataclass, pai_meta
  from tfaip.util.multiprocessing.parallelmap import tqdm_wrapper
  from tfaip.data.pipeline.definitions import PipelineMode
  from calamari_ocr.utils import glob_all
label_desc: Use image node_id 3 for calling the Codec obj's underlying member method code with example usage: obj.__post_init__() without return types