code: def get_entities(seq, suffix=False):
      
      # 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
docs: 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)]