code: def get_entities(seq, suffix=False):
      """Gets entities from sequence.
  
      Args:
          seq (list): sequence of labels.
  
      Returns:
          list: list of (chunk_type, chunk_start, chunk_end).
  
      Example:
          >>> from seqeval.metrics.sequence_labeling import get_entities
          >>> seq = ['B-PER', 'I-PER', 'O', 'B-LOC']
          >>> get_entities(seq)
          [('PER', 0, 1), ('LOC', 3, 3)]
      """
      # for nested list
      if any(isinstance(s, list) for s in seq):
          seq = [item for sublist in seq for item in sublist + ["O"]]
  
      prev_tag = "O"
      prev_type = ""
      begin_offset = 0
      chunks = []
      for i, chunk in enumerate(seq + ["O"]):
          if suffix:
              tag = chunk[-1]
              type_ = chunk.split("-")[0]
          else:
              tag = chunk[0]
              type_ = chunk.split("-")[-1]
  
          if end_of_chunk(prev_tag, tag, prev_type, type_):
              chunks.append((prev_type, begin_offset, i - 1))
          if start_of_chunk(prev_tag, tag, prev_type, type_):
              begin_offset = i
          prev_tag = tag
          prev_type = type_
  
      return chunks
  
file_path: nlp-architect/nlp_architect/utils/metrics.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  from scipy.stats import pearsonr, spearmanr
  from sklearn.metrics import f1_score
  from collections import defaultdict
  import numpy
label_desc: Use image node_id 7 for calling a global function with example usage: get_entities(seq, suffix) and returns: chunks