code: def is_valid(isbn_id):
      
      return (
          (not isbnlib.notisbn(isbn_id)) and (
              isbnlib.get_canonical_isbn(isbn_id) == isbn_id or
              isbnlib.mask(isbnlib.get_canonical_isbn(isbn_id)) == isbn_id)
      )
docs: Check that a given string is a valid ISBN.
  
      :param isbn_id: the isbn to be checked.
      :returns: boolean indicating whether the isbn is valid or not.
  
      >>> is_valid("978-3-16-148410-0")
      True
  
      >>> is_valid("9783161484100")
      True
  
      >>> is_valid("9783161484100aa")
      False
  
      >>> is_valid("abcd")
      False
  
      >>> is_valid("0136091814")
      True
  
      >>> is_valid("0136091812")
      False
  
      >>> is_valid("9780136091817")
      False
  
      >>> is_valid("123456789X")
      True