def update_config(config, new_config):
    """Updates configuration in a hierarchical level.

    For key-value pair {'a.b.c.d': v} in `new_config`, the `config` will be
    updated by

    config['a']['b']['c']['d'] = v
    """
    if new_config is None:
        return config

    assert isinstance(config, dict)
    assert isinstance(new_config, dict)

    for key, val in new_config.items():
        hierarchical_keys = key.split('.')
        temp = config
        for sub_key in hierarchical_keys[:-1]:
            temp = temp[sub_key]
        temp[hierarchical_keys[-1]] = val

    return config
Updates configuration in a hierarchical level.

    For key-value pair {'a.b.c.d': v} in `new_config`, the `config` will be
    updated by

    config['a']['b']['c']['d'] = v
    
utils/misc.py