def is_valid_bio(entity):
    """ check if the entity sequence is valid, 
    'I-' should not at the beginning, and should never follow 'O' neither. 
    """
    for j, e in enumerate(entity):
        if e.startswith('I-') and ( j == 0 or e[2:] != entity[j - 1][2:]):
            print(j, entity[j-1], e,)
            return False
    return True