docstr: evaluate on the given raw data
  
  Parameters
  ----------
  gt_data : Dataset, optional
      the ground truth
  pred_data : Dataset
      the prediction dataset
  
  Returns
  -------
  evaluation dictionary
docstr_tok: ["evaluate","on","the","given","raw","data","Parameters","--","--","--","--","--","gt_data",":","Dataset",",","optional","the","ground","truth","pred_data",":","Dataset","the","prediction","dataset","Returns","--","--","--","-","evaluation","dictionary"]
code: def evaluate(
      self, *, gt_data: Dict[str, str], pred_data: Dict[str, str]
  ):
      """evaluate on the given raw data
  
      Parameters
      ----------
      gt_data : Dataset, optional
          the ground truth
      pred_data : Dataset
          the prediction dataset
  
      Returns
      -------
      evaluation dictionary
      """
      if self.params.non_existing_pred_handling_mode != "error":
          n_empty = 0
          mapped_pred_data = {}
          for sample_id in list(gt_data.keys()):
              if sample_id in pred_data:
                  mapped_pred_data[sample_id] = pred_data[sample_id]
              else:
                  if (
                      self.params.non_existing_pred_handling_mode
                      == "empty"
                  ):
                      mapped_pred_data[sample_id] = ""
                  else:
                      del gt_data[sample_id]  # skip
                  n_empty += 1
          logger.info(
              f"{n_empty}/{len(gt_data)} lines could not be matched during the evaluation."
          )
          if n_empty == len(gt_data):
              raise ValueError(
                  f"No lines could be matched by their ID. First 10 gt ids "
                  f"{list(gt_data.keys())[:10]}, first 10 pred ids {list(pred_data.keys())[:10]}"
              )
          pred_data = mapped_pred_data
  
      gt_ids, pred_ids = set(gt_data.keys()), set(pred_data.keys())
      if len(gt_ids) != len(gt_data):
          raise ValueError("Non unique keys in ground truth data.")
      if gt_ids != pred_ids:
          raise Exception(
              f"Mismatch in gt and pred. Samples could not be matched by ID. "
              f"GT without PRED: {gt_ids.difference(pred_ids)}. "
              f"PRED without GT: {pred_ids.difference(gt_ids)}"
          )
  
      gt_pred = [(gt_data[s_id], pred_data[s_id]) for s_id in gt_ids]
      # evaluate single lines
      out = parallel_map(
          Evaluator.evaluate_single_args,
          [
              {
                  "gt": gt,
                  "pred": pred,
                  "skip_empty_gt": self.params.skip_empty_gt,
              }
              for gt, pred in gt_pred
          ],
          processes=self.params.setup.num_processes,
          progress_bar=self.params.progress_bar,
          desc="Evaluation",
      )
  
      res = Evaluator.evaluate_single_list(out, True)
      res["ids"] = gt_ids
      return res
  
file_path: calamari/calamari_ocr/ocr/evaluator.py
imports: from dataclasses import dataclass, field
  from typing import Dict, TYPE_CHECKING
  import logging
  from edit_distance import edit_distance
  from collections import namedtuple
  from paiargparse import pai_dataclass, pai_meta
  from tfaip.data.databaseparams import DataPipelineParams
  from tfaip.data.pipeline.definitions import PipelineMode
  from tfaip.util.multiprocessing.parallelmap import parallel_map, tqdm_wrapper
  from calamari_ocr.ocr.dataset.datareader.base import CalamariDataGeneratorParams
  from calamari_ocr.ocr.dataset.textprocessors import synchronize
label_desc: Use image node_id 7 for calling the Evaluator obj's underlying member method code with example usage: obj.evaluate() and returns: res