<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_underscore(s):
 """Transform camel or pascal case to underscore separated string """

    return re.sub(
            r'(?!^)([A-Z]+)',
            lambda m: "_{0}".format(m.group(1).lower()),
            re.sub(r'(?!^)([A-Z]{1}[a-z]{1})', lambda m: "_{0}".format(m.group(1).lower()), s)
        ).lower()