code: def main(trainer_params: "TrainerParams") -> Dict[str, AnyNumpy]:
      with ExitStack() as stack:
          if trainer_params.output_dir:
              stack.enter_context(
                  WriteToLogFile(
                      trainer_params.output_dir, append=False
                  )
              )
  
          logger.info(
              "trainer_params=" + trainer_params.to_json(indent=2)
          )
  
          # create the trainer and run it
          trainer = trainer_params.scenario.cls().create_trainer(
              trainer_params
          )
          return trainer.train()
  
file_path: calamari/calamari_ocr/scripts/train.py
imports: from contextlib import ExitStack
  from typing import TYPE_CHECKING, Dict
  from paiargparse import PAIArgumentParser
  from tfaip.util.logging import logger, WriteToLogFile
  from tfaip.util.typing import AnyNumpy
  from calamari_ocr import __version__
label_desc: Use image node_id 2 for calling a global function with example usage: main(trainer_params) and returns: trainer