code: def sequence_labeling_counts(true, predicted, equality_fn):
      """
      Return FP, FN, and TP counts
      """
      unique_classes = _get_unique_classes(true, predicted)
  
      d = {
          cls_: {
              "false_positives": [],
              "false_negatives": [],
              "true_positives": [],
          }
          for cls_ in unique_classes
      }
  
      for i, (true_annotations, predicted_annotations) in enumerate(
          zip(true, predicted)
      ):
          # add doc idx to make verification easier
          for annotations in [true_annotations, predicted_annotations]:
              for annotation in annotations:
                  annotation["doc_idx"] = i
  
          for true_annotation in true_annotations:
              for pred_annotation in predicted_annotations:
                  if equality_fn(true_annotation, pred_annotation):
                      if (
                          pred_annotation["label"]
                          == true_annotation["label"]
                      ):
                          d[true_annotation["label"]][
                              "true_positives"
                          ].append(true_annotation)
                          break
              else:
                  d[true_annotation["label"]]["false_negatives"].append(
                      true_annotation
                  )
  
          for pred_annotation in predicted_annotations:
              for true_annotation in true_annotations:
                  if (
                      equality_fn(true_annotation, pred_annotation)
                      and true_annotation["label"]
                      == pred_annotation["label"]
                  ):
                      break
              else:
                  d[pred_annotation["label"]]["false_positives"].append(
                      pred_annotation
                  )
  
      return d
  
imports: import os
  import copy
  from functools import partial
  from collections import defaultdict, OrderedDict
  import numpy
  from sklearn.metrics import confusion_matrix
  from tensorflow.python.platform import gfile
  from tensorflow.python.summary import summary_iterator
  import tabulate
  from finetune.encoding.input_encoder import get_spacy
label_desc: Use image node_id 20 for calling a global function with example usage: sequence_labeling_counts(true, predicted, equality_fn) and returns: d