code: def check_metrics(self, Y, Y_pred, expected, span_type=None):
      counts = get_seq_count_fn(span_type)(Y, Y_pred)
      precisions = seq_precision(Y, Y_pred, span_type=span_type)
      recalls = seq_recall(Y, Y_pred, span_type=span_type)
      micro_f1_score = sequence_f1(
          Y, Y_pred, span_type=span_type, average="micro"
      )
      per_class_f1s = sequence_f1(Y, Y_pred, span_type=span_type)
      weighted_f1 = sequence_f1(
          Y, Y_pred, span_type=span_type, average="weighted"
      )
      macro_f1 = sequence_f1(
          Y, Y_pred, span_type=span_type, average="macro"
      )
      for cls_ in counts:
          for metric in counts[cls_]:
              self.assertEqual(
                  len(counts[cls_][metric]),
                  expected[cls_][metric],
                  msg=f"class={cls_}, metric={metric}",
              )
          self.assertAlmostEqual(
              recalls[cls_],
              expected[cls_]["recall"],
              places=3,
              msg=f"class={cls_}",
          )
          self.assertAlmostEqual(
              per_class_f1s[cls_]["f1-score"],
              expected[cls_]["f1-score"],
              places=3,
              msg=f"class={cls_}",
          )
          self.assertAlmostEqual(
              precisions[cls_],
              expected[cls_]["precision"],
              places=3,
              msg=f"class={cls_}",
          )
      self.assertAlmostEqual(
          micro_f1_score, expected["micro-f1"], places=3
      )
      self.assertAlmostEqual(
          weighted_f1, expected["weighted-f1"], places=3
      )
      self.assertAlmostEqual(macro_f1, expected["macro-f1"], places=3)
  
imports: import unittest
  import pytest
  from finetune.util.metrics import seq_recall, seq_precision, get_seq_count_fn, micro_f1, sequence_f1, sequences_overlap
label_desc: Use image node_id 5 for calling the TestMetrics obj's underlying member method code with example usage: obj.check_metrics(Y, Y_pred, expected, span_type) without return types