code: def main(args: EvalArgs):
      # Local imports (imports that require tensorflow)
      from calamari_ocr.ocr.scenario import CalamariScenario
      from calamari_ocr.ocr.dataset.data import Data
      from calamari_ocr.ocr.evaluator import Evaluator
  
      if args.checkpoint:
          saved_model = SavedCalamariModel(
              args.checkpoint, auto_update=True
          )
          trainer_params = (
              CalamariScenario.trainer_cls()
              .params_cls()
              .from_dict(saved_model.dict)
          )
          data_params = trainer_params.scenario.data
      else:
          data_params = Data.default_params()
  
      data = Data(data_params)
  
      pred_data = (
          args.pred
          if args.pred is not None
          else args.gt.to_prediction()
      )
      evaluator = Evaluator(args.evaluator, data=data)
      evaluator.preload_gt(gt_dataset=args.gt)
      r = evaluator.run(gt_dataset=args.gt, pred_dataset=pred_data)
  
      # TODO: More output
      print("Evaluation result")
      print("=================")
      print("")
      print(
          "Got mean normalized label error rate of {:.2%} ({} errs, {} total chars, {} sync errs)".format(
              r["avg_ler"],
              r["total_char_errs"],
              r["total_chars"],
              r["total_sync_errs"],
          )
      )
  
      # sort descending
      print_confusions(r, args.n_confusions)
      print_worst_lines(r, args.n_worst_lines)
  
      if args.xlsx_output:
          write_xlsx(
              args.xlsx_output,
              [
                  {
                      "prefix": "evaluation",
                      "results": r,
                      "gt_files": r["ids"],
                  }
              ],
          )
  
      return r
  
file_path: calamari/calamari_ocr/scripts/eval.py
imports: from dataclasses import dataclass, field
  from typing import Optional
  import tfaip.util.logging
  import numpy
  from calamari_ocr.ocr.dataset.params import DATA_GENERATOR_CHOICES
  from paiargparse import PAIArgumentParser, pai_dataclass, pai_meta
  from calamari_ocr.ocr import SavedCalamariModel
  from calamari_ocr.ocr.dataset.datareader.base import CalamariDataGeneratorParams
  from calamari_ocr.ocr.dataset.datareader.file import FileDataParams
  from calamari_ocr.ocr.evaluator import EvaluatorParams
label_desc: Use image node_id 6 for calling a global function with example usage: main(args) and returns: r