import typing
import re


def to_snake(d: typing.Dict[str, typing.Any]) -> typing.Dict[str, typing.Any]:
    """Converts dictionary keys from camel case to snake case."""

    def convert(key: str) -> str:
        camel = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", key)
        return re.sub("([a-z0-9])([A-Z])", r"\1_\2", camel).lower()

    return {convert(k): v for k, v in d.items()}