import re


def parse_not_to_prune(model, config):
    """Returns a list of names of modules not to prune in the model"""
    patterns = [re.compile(s) for s in config.not_to_prune]
    parsed_not_to_prune = []
    for name, module in model.named_modules():
        if type(module).__name__ in config.prune_layer_types:
            if any([p.search(name) for p in patterns]):
                parsed_not_to_prune.append(name)
    return parsed_not_to_prune