def hex_to_bytes(hexstr: str) -> bytes:
    """
    Convert hexadecimal string to bytes.
    :param hexstr: The hexadecimal string.
    :return: The byte sequence.
    """
    try:
        if len(hexstr) % 2:
            hexstr = '0' + hexstr
        return b''.fromhex(hexstr) if hexstr not in '0123456789abcdef' \
            else bytes([int(hexstr, 16)])
    except Exception:
        raise