code: def _metric(self, inputs, targets, outputs) -> List[AnyTensor]:
      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,
          )
  
      # 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
      sw = K.flatten(targets["gt_len"])
      return [
          self.cer_total(
              cer(outputs["decoded"], targets["gt"], targets["gt_len"]),
              sample_weight=sw,
          )
      ] + [
          self.sub_cer[i](
              cer(
                  outputs[f"decoded_{i}"],
                  targets["gt"],
                  targets["gt_len"],
              ),
              sample_weight=sw
              * tf.cast(
                  tf.equal(K.flatten(targets["fold_id"]), i), tf.int32
              ),
          )
          for i in range(self.params.ensemble)
      ]
  
imports: from dataclasses import dataclass
  import tensorflow
  from typing import Dict, List, Tuple
  import bidi.algorithm
  import Levenshtein
  from paiargparse import pai_dataclass
  from tfaip import Sample
  from tfaip.model.modelbase import ModelBase
  from tfaip.util.tftyping import AnyTensor
  from calamari_ocr.ocr.model.params import ModelParams
  from tensorflow.python.ops import math_ops
  from calamari_ocr.ocr.model.ensemblegraph import EnsembleGraph
label_desc: Use image node_id 4 for calling the EnsembleModel obj's underlying member method code with example usage: obj._metric(inputs, targets, outputs) and returns: unknown, tf