def out_of_bounds(subject, start, end):
    """Tests if a subject overlaps with or is outside of a given range."""
    return (
        subject.end < start
        or subject.start < start < subject.end
        or subject.start < end < subject.end
        or subject.start > end
    )