code: def convert_text_processor(proc: dict):
      flat = []
  
      def recurse_convert(p: dict):
          t = p.get("type", "DEFAULT_NORMALIZER")
          if t == "DEFAULT_NORMALIZER":
              flat.extend(default_text_preprocessor())
          elif t == "DEFAULT_PRE_NORMALIZER":
              flat.extend(default_text_preprocessor())
          elif t == "DEFAULT_POST_NORMALIZER":
              flat.extend(default_text_preprocessor())
          elif t == "MULTI_NORMALIZER":
              for c in p["children"]:
                  recurse_convert(c)
          elif t == "NOOP_NORMALIZER":
              pass
          elif t == "STRIP_NORMALIZER":
              flat.append(text_processor("StripTextProcessor"))
          elif t == "BIDI_NORMALIZER":
              conv = {
                  "BIDI_AUTO": None,
                  "BIDI_LTR": "L",
                  "BIDI_RTL": "R",
              }
              flat.append(
                  text_processor(
                      "BidiTextProcessor",
                      args={
                          "bidi_direction": conv[
                              p.get("bidiDirection", "BIDI_AUTO")
                          ]
                      },
                  )
              )
          elif t == "TEXT_NORMALIZER":
              conv = ["NFC", "NFKC", "NFD", "NFKD"]
              value = p.get("unicodeNormalization", 0)
              if isinstance(value, int):
                  value = conv[value]
              else:
                  assert value in conv, f"{value} not in {conv}"
              flat.append(
                  text_processor(
                      "TextNormalizer",
                      args={"unicode_normalization": value},
                  )
              )
          elif t == "TEXT_REGULARIZER":
              flat.append(
                  text_processor(
                      "TextRegularizer",
                      args={"replacements": p.get("replacements", [])},
                  )
              )
          elif t == "STR_TO_CHAR_LIST":
              flat.append(
                  text_processor("StrToCharList"),
                  args={"chars": p.get("characters", [])},
              )
          else:
              raise ValueError(f"Unknown type {t}")
  
      recurse_convert(proc)
      return flat
  
imports: import inspect
  import os
  from typing import Optional
  import logging
  import h5py
  from tensorflow import keras
  from tensorflow.python.keras.saving.hdf5_format import load_weights_from_hdf5_group
  from tfaip.util.tfaipargparse import post_init
  from calamari_ocr.ocr.savedmodel.migrations.version3_4to5 import migrate3to5
  from calamari_ocr.ocr.scenario import CalamariScenario
  from calamari_ocr.ocr.training.params import TrainerParams
label_desc: Use image node_id 6 for calling a global function with example usage: convert_text_processor(proc) and returns: flat