def METHOD_NAME(**tokens):
    # Create a pattern for non-escaped tokens, in the form:
    #   (?<!\\)(?:a|b|c...)
    # This is meant to match patterns a, b, or c, or ... if they are not
    # preceded by a backslash.
    # where a, b, c... are in the form
    #   (?P<name>pattern)
    # which matches the pattern and captures it in a named match group.
    # The group names and patterns are given as arguments.
    all_tokens = "|".join(
        "(?P<%s>%s)" % (name, value) for name, value in tokens.items()
    )
    nonescaped = r"(?<!\\)(?:%s)" % all_tokens
    # The final pattern matches either the above pattern, or an escaped
    # backslash, captured in the "escape" match group.
    return re.compile("(?:%s|%s)" % (nonescaped, r"(?P<escape>\\\\)"))