def embbed_search_space(sp, prefix):
    """ Add a prefix to each key of search space. """
    if type(sp) == dict:
        return {f'{prefix}__{k}': v for k, v in sp.items()}
    else:
        return [embbed_search_space(d, prefix) for d in sp]