Micro1's assessment platform receives bracket sequences that must be checked before further parsing. Given a string containing only (, ), {, }, [, and ], determine whether the sequence is valid using a stack.
A string is valid when every opening bracket is closed by the matching bracket type, brackets close in the correct last-in, first-out order, and no closing bracket appears without a corresponding opening bracket.
Implement is_valid(s), where s is a string. Return True if the bracket sequence is valid, otherwise return False.
The empty string is considered valid.
def is_valid(s):