in summarize_from_feedback/utils/hyperparams.py [0:0]
def flat_to_nested(flat_dict, separator="."):
nested_dict = dict()
for k, v in flat_dict.items():
parts = k.split(separator)
d = nested_dict
subkey = None
for part in parts[:-1]:
subkey = part if subkey is None else subkey + separator + part
if part not in d:
d[part] = dict()
if not isinstance(d[part], dict):
raise ValueError(f"Set conflicting values for {subkey}")
d = d[part]
if parts[-1] in d:
raise ValueError(f"Set conflicting values for {k}")
d[parts[-1]] = v
return nested_dict