def has_bio_error(prev_label, curr_label):
    """
    Check whether a BIO error occurred by comparing the current label with the previous label.
    Examples for incorrect BIO tags:
        1. I- follows I- of another type
           1    Hello   B-ABC
           2    World   I-ABC
           3    !       I-XYZ
        2. I- after O
           1    Hello   O
           2    World   I-ABC
           3    !       I-ABC

    Args:
        prev_label (Label): Previous label
        curr_label (Label): Current label

    Returns:
        bool: Whether or not a BIO error occurred
    """
    i_follows_o = prev_label.is_o and curr_label.is_i
    i_follows_other_component = all([
        curr_label.is_i,
        any([
            # The types differ
            prev_label.type != curr_label.type,
            # OR: the types are equal, but the relation type differs
            all([
                prev_label.type == curr_label.type,
                prev_label.rel_type is not None,
                curr_label.rel_type is not None,
                prev_label.rel_type != curr_label.rel_type
            ])
        ])
    ])

    return i_follows_o or i_follows_other_component