import re


def to_snake_case(x: str) -> str:
    """Return snake_case of x.

    Args:
        x (str): The string that has to be converted to snake case.

    Returns:
        str: Snake case of x.
    """

    x_s = x
    x_s = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', x_s)
    return re.sub('([a-z0-9])([A-Z])', r'\1_\2', x_s).lower()