code: def print_confusions(r, n_confusions):
      # sort descending
      if n_confusions != 0 and r["total_sync_errs"] > 0:
          total_percent = 0
          keys = sorted(
              r["confusion"].items(), key=lambda item: -item[1]
          )
          print(
              "{:8s} {:8s} {:8s} {:10s}".format(
                  "GT", "PRED", "COUNT", "PERC (CER)"
              )
          )
  
          for i, ((gt, pred), count) in enumerate(keys):
              gt_fmt = "{" + gt + "}"
              pred_fmt = "{" + pred + "}"
              if i == n_confusions:
                  break
  
              percent = (
                  count * max(len(gt), len(pred)) / r["total_sync_errs"]
              )
              print(
                  "{:8s} {:8s} {:8d} {:10.2%}".format(
                      gt_fmt, pred_fmt, count, percent
                  )
              )
              total_percent += percent
  
          print(
              "The remaining but hidden errors make up {:.2%}".format(
                  1.0 - total_percent
              )
          )
  
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 1 for calling a global function with example usage: print_confusions(r, n_confusions) without return types