code: def write_xlsx(xlsx_file, eval_datas):
      logger.info("Writing xlsx file to {}".format(xlsx_file))
      import xlsxwriter
  
      workbook = xlsxwriter.Workbook(xlsx_file)
  
      for eval_data in eval_datas:
          prefix = eval_data["prefix"]
          r = eval_data["results"]
          gt_files = eval_data["gt_files"]
  
          # all files
          ws = workbook.add_worksheet("{} - per line".format(prefix))
  
          for i, heading in enumerate(
              [
                  "GT FILE",
                  "GT",
                  "PRED",
                  "LEN",
                  "ERR",
                  "CER",
                  "REL. ERR",
                  "SYNC ERR",
                  "CONFUSIONS",
              ]
          ):
              ws.write(0, i, heading)
  
          sorted_lines = sorted(
              zip(r["single"], gt_files), key=lambda a: -a[0][1]
          )
  
          all_cs = []
          for i, (
              (len_gt, errs, sync_errs, confusion, (gt, pred)),
              gt_file,
          ) in enumerate(sorted_lines):
              ws.write(i + 1, 0, gt_file)
              ws.write(i + 1, 1, gt.strip())
              ws.write(i + 1, 2, pred.strip())
              ws.write(i + 1, 3, len_gt)
              ws.write(i + 1, 4, errs)
              ws.write(i + 1, 5, errs / max(len(gt), len(pred), 1))
              ws.write(
                  i + 1,
                  6,
                  errs / r["total_char_errs"]
                  if r["total_char_errs"] > 0
                  else 0,
              )
              ws.write(i + 1, 7, sync_errs)
              ws.write(i + 1, 8, "{}".format(confusion))
              all_cs.append(errs / max(len(gt), len(pred), 1))
  
          # total confusions
          ws = workbook.add_worksheet("{} - global".format(prefix))
          for i, heading in enumerate(
              ["GT", "PRED", "COUNT", "PERC (CER)"]
          ):
              ws.write(0, i, heading)
  
          keys = sorted(
              r["confusion"].items(), key=lambda item: -item[1]
          )
  
          for i, ((gt, pred), count) in enumerate(keys):
              gt_fmt = "{" + gt + "}"
              pred_fmt = "{" + pred + "}"
  
              percent = (
                  count * max(len(gt), len(pred)) / r["total_sync_errs"]
              )
              ws.write(i + 1, 0, gt_fmt)
              ws.write(i + 1, 1, pred_fmt)
              ws.write(i + 1, 2, count)
              ws.write(i + 1, 3, percent)
  
          # histogram of cers
          hsl = "{} - histogram".format(prefix)
          ws = workbook.add_worksheet(hsl)
          ws.write_row("A1", ["Class", "Count"])
          hist, bin_edges = np.histogram(all_cs, bins="auto")
          ws.write_column("A2", bin_edges)
          ws.write_column("B2", hist)
  
          chart = workbook.add_chart({"type": "column"})
          chart.add_series(
              {
                  "name": "CER hist",
                  "categories": "='{}'!$A$2:$A${}".format(
                      hsl, 2 + len(bin_edges)
                  ),
                  "values": "='{}'!$B$2:$B${}".format(
                      hsl, 2 + len(bin_edges)
                  ),
              }
          )
          chart.set_title({"name": "CER distribution"})
          chart.set_x_axis({"name": "CER"})
          chart.set_y_axis({"name": "Amount"})
  
          ws.insert_chart("D2", chart, {"x_offset": 25, "y_offset": 10})
  
      workbook.close()
  
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 3 for calling a global function with example usage: write_xlsx(xlsx_file, eval_datas) without return types