def setup_adapter(args, adapter_args, model, train_adapter=True, load_adapter=None, load_lang_adapter=None):
    task_name = (args.task_name or 'ner')
    if (task_name not in model.config.adapters.adapter_list(AdapterType.text_task)):
        logging.info('Trying to decide if add adapter')
        adapter_config = AdapterConfig.load(adapter_args.adapter_config, non_linearity=adapter_args.adapter_non_linearity, reduction_factor=adapter_args.adapter_reduction_factor)
        if (adapter_args.load_adapter or load_adapter):
            logging.info('loading task adapter')
            model.load_adapter((adapter_args.load_adapter if (load_adapter is None) else load_adapter), AdapterType.text_task, config=adapter_config, load_as=task_name)
        else:
            logging.info('Adding task adapter')
            model.add_adapter(task_name, AdapterType.text_task, config=adapter_config)
    if (adapter_args.load_lang_adapter or load_lang_adapter):
        if (load_lang_adapter is None):
            logging.info('loading lang adpater {}'.format(adapter_args.load_lang_adapter))
            lang_adapter_config = AdapterConfig.load(adapter_args.lang_adapter_config, non_linearity=adapter_args.lang_adapter_non_linearity, reduction_factor=adapter_args.lang_adapter_reduction_factor)
        else:
            logging.info('loading lang adpater {}'.format(load_lang_adapter))
            lang_adapter_config = AdapterConfig.load(adapter_args.lang_adapter_config, non_linearity=adapter_args.lang_adapter_non_linearity, reduction_factor=adapter_args.lang_adapter_reduction_factor)
    else:
        lang_adapter_name = None
        lang_adapter_names = []
    model.train_adapter([task_name])
    if lang_adapter_name:
        model.set_active_adapters([lang_adapter_names, [task_name]])
    else:
        model.set_active_adapters([task_name])
    return (model, lang_adapter_names, task_name)
def setup_adapter(args, adapter_args, model, train_adapter=True, load_adapter=None, load_lang_adapter=None):
    task_name = (args.task_name or 'ner')
    if (task_name not in model.config.adapters.adapter_list(AdapterType.text_task)):
        logging.info('Trying to decide if add adapter')
        adapter_config = AdapterConfig.load(adapter_args.adapter_config, non_linearity=adapter_args.adapter_non_linearity, reduction_factor=adapter_args.adapter_reduction_factor)
        if (adapter_args.load_adapter or load_adapter):
            logging.info('loading task adapter')
            model.load_adapter((adapter_args.load_adapter if (load_adapter is None) else load_adapter), AdapterType.text_task, config=adapter_config, load_as=task_name)
        else:
            logging.info('Adding task adapter')
            model.add_adapter(task_name, AdapterType.text_task, config=adapter_config)
    if (adapter_args.load_lang_adapter or load_lang_adapter):
        if (load_lang_adapter is None):
            logging.info('loading lang adpater {}'.format(adapter_args.load_lang_adapter))
            lang_adapter_config = AdapterConfig.load(adapter_args.lang_adapter_config, non_linearity=adapter_args.lang_adapter_non_linearity, reduction_factor=adapter_args.lang_adapter_reduction_factor)
        else:
            logging.info('loading lang adpater {}'.format(load_lang_adapter))
            lang_adapter_config = AdapterConfig.load(adapter_args.lang_adapter_config, non_linearity=adapter_args.lang_adapter_non_linearity, reduction_factor=adapter_args.lang_adapter_reduction_factor)
    else:
        lang_adapter_name = None
        lang_adapter_names = []
    model.train_adapter([task_name])
    if lang_adapter_name:
        model.set_active_adapters([lang_adapter_names, [task_name]])
    else:
        model.set_active_adapters([task_name])
    return (model, lang_adapter_names, task_name)