def flatten_dict(
    d: t.MutableMapping[str, t.Any],
    parent: str = "",
    sep: str = ".",
) -> t.Generator[tuple[str, t.Any], None, None]:
    """Flatten nested dictionary into a single level dictionary."""
    for k, v in d.items():
        k = f'"{k}"' if any(i in punctuation for i in k) else k
        nkey = parent + sep + k if parent else k
        if isinstance(v, t.MutableMapping):
            yield from flatten_dict(
                t.cast(t.MutableMapping[str, t.Any], v), parent=nkey, sep=sep
            )
        else:
            yield nkey, v
Flatten nested dictionary into a single level dictionary.
src/bentoml/_internal/configuration/helpers.py