def deep_update(cfg, other):
    """deep_update recursively mutates `cfg`, copying items from `other`,
    recursing when both values are dictionaries and overriding otherwise"""
    for key in other.keys():
        if (
            isinstance(other[key], dict)
            and key in cfg
            and isinstance(cfg[key], dict)
            and not key.endswith("_map")
        ):
            deep_update(cfg[key], other[key])
        else:
            cfg[key] = other[key]
    return cfg