def build_reg_from_config(model, reg_config):
    """
    This function build regularizer given the model (only need for weigths typically)
    and regularizer configuration.
    """
    reg_class = reg_config['class']
    reg_args = {k: v for k, v in reg_config.items() if k != 'class'}
    reg = globals()[reg_class](model, **reg_args)
    return reg