code: def _metric(
      self,
      inputs: Dict[str, tf.Tensor],
      targets: Dict[str, tf.Tensor],
      outputs: Dict[str, tf.Tensor],
  ) -> List[tf.Tensor]:
      # Note for codec change: the codec size is derived upon creation, therefore the ctc ops must be created
      # using the true codec size (the W/B-Matrix may change its shape however during loading/codec change
      # to match the true codec size
      def cer(decoded, targets, targets_length):
          greedy_decoded = tf.sparse.from_dense(decoded)
          sparse_targets = tf.cast(
              K.ctc_label_dense_to_sparse(
                  targets,
                  math_ops.cast(
                      K.flatten(targets_length), dtype="int32"
                  ),
              ),
              "int32",
          )
          return tf.edit_distance(
              tf.cast(greedy_decoded, tf.int32),
              sparse_targets,
              normalize=True,
          )
  
      return [
          self.cer_metric(
              cer(outputs["decoded"], targets["gt"], targets["gt_len"]),
              sample_weight=K.flatten(targets["gt_len"]),
          )
      ]
  
file_path: calamari/calamari_ocr/ocr/model/model.py
imports: from typing import Dict, List, Tuple
  import Levenshtein
  import bidi.algorithm
  import tensorflow
  from tensorflow.python.ops import math_ops
  from tfaip import Sample
  from tfaip.model.modelbase import ModelBase
  from calamari_ocr.ocr.model.params import ModelParams
label_desc: Use image node_id 4 for calling the Model obj's underlying member method code with example usage: obj._metric(inputs, targets, outputs) and returns: list, tf