from typing import NamedTuple


def dump_config(fields: NamedTuple):
    """
    Convert config structures back to raw configs.

    :param fields: the config instance to be dumped
    :return: raw configs, a python dict
    """

    assert hasattr(fields, '_field_types')
    config = {}
    for k, v in fields._asdict().items():
        if v is None:
            continue
        if hasattr(v, '_field_types'):
            config[k] = dump_config(v)
        else:
            config[k] = v
    return config