code: def compute_f1_score(self, preds, gts):
      ignores = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 25]
      C = preds.shape[1]
      classes = np.array(sorted(set(range(C)) - set(ignores)))
      hist = (
          np.bincount(
              (gts * C).astype("int64") + preds.argmax(1),
              minlength=C**2,
          )
          .reshape([C, C])
          .astype("float32")
      )
      diag = np.diag(hist)
      recalls = diag / hist.sum(1).clip(min=1)
      precisions = diag / hist.sum(0).clip(min=1)
      f1 = (
          2
          * recalls
          * precisions
          / (recalls + precisions).clip(min=1e-8)
      )
      return f1[classes]
  
file_path: PaddleOCR/ppocr/metrics/kie_metric.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import paddle
label_desc: Use image node_id 3 for calling the KIEMetric obj's underlying member method code with example usage: obj.compute_f1_score(preds, gts) and returns: f1