import re


def camel_to_snake_case(camel_str) -> str:
    """
    convert a camel case string to snake case.
    """
    camel_str = re.sub(r"((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))", r"_\1", camel_str)
    return camel_str.lower().lstrip("_")