def flatten_config_dict(x, prefix=""):
    """Flattens config dict into single layer dict

    Example:
        flatten_config_dict({
            MODEL: {
                FBNET_V2: {
                    ARCH_DEF: "val0"
                }
            }
        })
        => {"MODEL.FBNET_V2.ARCH_DEF": "val0"}
    """
    if not isinstance(x, dict):
        return {prefix: x}

    d = {}
    for k, v in x.items():
        new_key = f"{prefix}.{k}" if prefix else k
        d.update(flatten_config_dict(v, new_key))
    return d