code: def performance_measure(
      y_true: List[List[str]], y_pred: List[List[str]]
  ) -> Dict[str, int]:
      """
      Compute the performance metrics: TP, FP, FN, TN
      Args:
          y_true : 2d array. Ground truth (correct) target values.
          y_pred : 2d array. Estimated targets as returned by a tagger.
      Returns:
          performance_dict : dict
      Example:
          >>> from kashgari.metrics.sequence_labeling import performance_measure
          >>> y_true = [['O', 'O', 'O', 'B-MISC', 'I-MISC', 'O', 'B-ORG'], ['B-PER', 'I-PER', 'O']]
          >>> y_pred = [['O', 'O', 'B-MISC', 'I-MISC', 'I-MISC', 'O', 'O'], ['B-PER', 'I-PER', 'O']]
          >>> performance_measure(y_true, y_pred)
          (3, 3, 1, 4)
      """
      performance_dict = dict()
      y_true_all = [item for sublist in y_true for item in sublist]
      y_pred_all = [item for sublist in y_pred for item in sublist]
  
      performance_dict["TP"] = sum(
          y_t == y_p
          for y_t, y_p in zip(y_true_all, y_pred_all)
          if ((y_t != "O") or (y_p != "O"))
      )
      performance_dict["FP"] = sum(
          y_t != y_p for y_t, y_p in zip(y_true_all, y_pred_all)
      )
      performance_dict["FN"] = sum(
          ((y_t != "O") and (y_p == "O"))
          for y_t, y_p in zip(y_true_all, y_pred_all)
      )
      performance_dict["TN"] = sum(
          (y_t == y_p == "O")
          for y_t, y_p in zip(y_true_all, y_pred_all)
      )
  
      return performance_dict
  
file_path: Kashgari/kashgari/metrics/sequence_labeling.py
imports: from collections import defaultdict
  from typing import List, Dict, Tuple, Any
  import numpy
label_desc: Use image node_id 9 for calling a global function with example usage: performance_measure(y_true, y_pred) and returns: performance_dict