code: def count_chunks(true_seqs, pred_seqs):
      """
      true_seqs: a list of true tags
      pred_seqs: a list of predicted tags
      return:
      correct_chunks: a dict (counter),
                      key = chunk types,
                      value = number of correctly identified chunks per type
      true_chunks:    a dict, number of true chunks per type
      pred_chunks:    a dict, number of identified chunks per type
      correct_counts, true_counts, pred_counts: similar to above, but for tags
      """
      correct_chunks = defaultdict(int)
      true_chunks = defaultdict(int)
      pred_chunks = defaultdict(int)
  
      correct_counts = defaultdict(int)
      true_counts = defaultdict(int)
      pred_counts = defaultdict(int)
  
      prev_true_tag, prev_pred_tag = "O", "O"
      correct_chunk = None
  
      for true_tag, pred_tag in zip(true_seqs, pred_seqs):
          if true_tag == pred_tag:
              correct_counts[true_tag] += 1
          true_counts[true_tag] += 1
          pred_counts[pred_tag] += 1
  
          _, true_type = split_tag(true_tag)
          _, pred_type = split_tag(pred_tag)
  
          if correct_chunk is not None:
              true_end = is_chunk_end(prev_true_tag, true_tag)
              pred_end = is_chunk_end(prev_pred_tag, pred_tag)
  
              if pred_end and true_end:
                  correct_chunks[correct_chunk] += 1
                  correct_chunk = None
              elif pred_end != true_end or true_type != pred_type:
                  correct_chunk = None
  
          true_start = is_chunk_start(prev_true_tag, true_tag)
          pred_start = is_chunk_start(prev_pred_tag, pred_tag)
  
          if true_start and pred_start and true_type == pred_type:
              correct_chunk = true_type
          if true_start:
              true_chunks[true_type] += 1
          if pred_start:
              pred_chunks[pred_type] += 1
  
          prev_true_tag, prev_pred_tag = true_tag, pred_tag
      if correct_chunk is not None:
          correct_chunks[correct_chunk] += 1
  
      return (
          correct_chunks,
          true_chunks,
          pred_chunks,
          correct_counts,
          true_counts,
          pred_counts,
      )
  
file_path: graph4nlp/examples/pytorch/name_entity_recognition/conlleval.py
imports: from __future__ import division, print_function, unicode_literals
  import sys
  from collections import defaultdict
label_desc: Use image node_id 5 for calling a global function with example usage: count_chunks(true_seqs, pred_seqs) and returns: correct_chunks,  true_chunks,  pred_chunks,  correct_counts,  true_counts,  pred_counts