def _update_and_verify_sub_config(cfg, allowed_cfg, dataset_name):
    """
    Update and verify local config.

    Parameters
    ----------
    cfg: dict
        Config to be checked and updated.
    allowed_cfg: dict
        Config containing list of allowed values or subdict with list of allowed
        values per dataset.
    dataset_name: str
        Name of the dataset being used.

    Returns
    -------
    cfg : dict
        Updated config.
    """

    for k, v in allowed_cfg.items():
        if isinstance(v, dict) and dataset_name in v.keys():
            v = v[dataset_name]

        if k not in cfg:
            cfg[k] = v[0]
            print(f"Warning: dataset.{k} not set. Using default value {v[0]}")
        elif cfg[k] not in v:
            raise ValueError(f"dataset.{k} must be in {v}.")
    return cfg