def get_entities(seq: list):
    """Gets entities from sequence.
    @param seq:
        sequence of labels.
    @return: list
        list of (chunk_type, index).

    Example:
        >>> seq = ['REL', 'REL', 'O', '[SEP]']
        >>> get_entities(seq)
        [('REL', 0), ('REL', 1), ('SEP', 3)]
    """
    # for nested list
    if any(isinstance(s, list) for s in seq):
        seq = [item for sublist in seq for item in sublist + ['O']]
    return [(label, i) for i, label in enumerate(seq) if label != 'O']