<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def norm_pattern(pattern, normalize, is_raw_chars):
 r""" Normalize pattern. - For windows systems we want to normalize slashes to \. - If raw string chars is enabled, we want to also convert encoded string chars to literal characters. - If `normalize` is enabled, take care to convert \/ to \\\\. """


    is_bytes = isinstance(pattern, bytes)

    if not normalize and not is_raw_chars:
        return pattern

    def norm_char(token):
        """Normalize slash."""

        if normalize and token in ('/', b'/'):
            token = br'\\' if is_bytes else r'\\'
        return token

    def norm(m):
        """Normalize the pattern."""

        if m.group(1):
            char = m.group(1)
            if normalize:
                char = br'\\\\' if is_bytes else r'\\\\' if len(char) > 1 else norm_char(char)
        elif m.group(2):
            char = norm_char(BACK_SLASH_TRANSLATION[m.group(2)] if is_raw_chars else m.group(2))
        elif is_raw_chars and m.group(4):
            char = norm_char(bytes([int(m.group(4), 8) & 0xFF]) if is_bytes else chr(int(m.group(4), 8)))
        elif is_raw_chars and m.group(3):
            char = norm_char(bytes([int(m.group(3)[2:], 16)]) if is_bytes else chr(int(m.group(3)[2:], 16)))
        elif is_raw_chars and not is_bytes and m.group(5):
            char = norm_char(unicodedata.lookup(m.group(5)[3:-1]))
        elif not is_raw_chars:
            char = m.group(0)
        else:
            value = m.group(5) if is_bytes else m.group(6)
            pos = m.start(5) if is_bytes else m.start(6)
            raise SyntaxError("Could not convert character value %s at position %d" % (value, pos))
        return char

    return (RE_BNORM if is_bytes else RE_NORM).sub(norm, pattern)