import re


def get_model_presets(config, model):
    """Collect all the parameters model from the UI and return them as a dict.

    Args:
        config (dict): Recipe config dictionary obtained with dataiku.customrecipe.get_recipe_config().
        model (str): Model name found in the UI.

    Returns:
        Dictionary of model parameters to be used as kwargs in gluonts Predictor.
    """
    model_presets = {}
    matching_key = f"{model}_model_(.*)"
    for key in config:
        key_search = re.match(matching_key, key, re.IGNORECASE)
        if key_search:
            key_type = key_search.group(1)
            model_presets.update({key_type: config[key]})
    return model_presets