<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def snake_to_camel(s, upper=True):
 """Convert from snake_case to CamelCase If upper is set, then convert to upper CamelCase, otherwise the first character keeps its case. """

    s = _re_snake_to_camel.sub(lambda m: m.group(2).upper(), s)
    if upper:
        s = s[:1].upper() + s[1:]
    return s