code: def trainer(
      EXP_PATH,
      config,
      Processor,
      train_dataset=None,
      valid_dataset=None,
      test_dataset=None,
      resume=None,
      test=None,
      zero=False,
  ):
      if not os.path.exists(EXP_PATH):
          os.mkdir(EXP_PATH)
      config.logging.path = EXP_PATH
      # set seed
      set_seed(config.reproduce.seed)
  
      # load the pretrained models, its model, tokenizer, and config.
      (
          plm_model,
          plm_tokenizer,
          plm_config,
          plm_wrapper_class,
      ) = load_plm_from_config(config)
  
      # define template and verbalizer
      if config.task == "classification":
          # define prompt
          template = load_template(
              config=config,
              model=plm_model,
              tokenizer=plm_tokenizer,
              plm_config=plm_config,
          )
          verbalizer = load_verbalizer(
              config=config,
              model=plm_model,
              tokenizer=plm_tokenizer,
              plm_config=plm_config,
              classes=Processor.labels,
          )
          # load prompt’s pipeline model
          prompt_model = PromptForClassification(
              plm_model,
              template,
              verbalizer,
              freeze_plm=config.plm.optimize.freeze_para,
          )
  
      elif config.task == "generation":
          template = load_template(
              config=config,
              model=plm_model,
              tokenizer=plm_tokenizer,
              plm_config=plm_config,
          )
          prompt_model = PromptForGeneration(
              plm_model,
              template,
              freeze_plm=config.plm.optimize.freeze_para,
              gen_config=config.generation,
          )
      else:
          raise NotImplementedError(
              f"config.task {config.task} is not implemented yet. Only classification and generation are supported."
          )
  
      # process data and get data_loader
      train_dataloader = (
          build_dataloader(
              train_dataset,
              template,
              plm_tokenizer,
              plm_wrapper_class,
              config,
              "train",
          )
          if train_dataset
          else None
      )
      valid_dataloader = (
          build_dataloader(
              valid_dataset,
              template,
              plm_tokenizer,
              plm_wrapper_class,
              config,
              "dev",
          )
          if valid_dataset
          else None
      )
      test_dataloader = (
          build_dataloader(
              test_dataset,
              template,
              plm_tokenizer,
              plm_wrapper_class,
              config,
              "test",
          )
          if test_dataset
          else None
      )
  
      if config.task == "classification":
          if (
              config.classification.auto_t
              or config.classification.auto_v
          ):
              runner = LMBFFClassificationRunner(
                  train_dataset=train_dataset,
                  valid_dataset=valid_dataset,
                  test_dataset=test_dataset,
                  template=template,
                  verbalizer=verbalizer,
                  config=config,
              )
          elif config.verbalizer == "proto_verbalizer":
              runner = ProtoVerbClassificationRunner(
                  model=prompt_model,
                  train_dataloader=train_dataloader,
                  valid_dataloader=valid_dataloader,
                  test_dataloader=test_dataloader,
                  id2label=Processor.id2label,
                  config=config,
              )
          else:
              runner = ClassificationRunner(
                  model=prompt_model,
                  train_dataloader=train_dataloader,
                  valid_dataloader=valid_dataloader,
                  test_dataloader=test_dataloader,
                  id2label=Processor.id2label,
                  config=config,
              )
      elif config.task == "generation":
          runner = GenerationRunner(
              model=prompt_model,
              train_dataloader=train_dataloader,
              valid_dataloader=valid_dataloader,
              test_dataloader=test_dataloader,
              config=config,
          )
  
      if zero:
          res = runner.test()
      elif test:
          res = runner.test(ckpt="best")
      elif resume:
          res = runner.run(ckpt="last")
      else:
          res = runner.run()
      return res
  
file_path: OpenPrompt/experiments/cli.py
imports: import os
  import sys
  import argparse
  from openprompt.trainer import ClassificationRunner, GenerationRunner
  from openprompt.lm_bff_trainer import LMBFFClassificationRunner
  from openprompt.protoverb_trainer import ProtoVerbClassificationRunner
  from re import template
  from openprompt.pipeline_base import PromptForClassification, PromptForGeneration
  from openprompt.utils.reproduciblity import set_seed
  from openprompt import PromptDataLoader
  from openprompt.prompts import load_template, load_verbalizer, load_template_generator, load_verbalizer_generator
  from openprompt.data_utils import FewShotSampler
  from openprompt.utils.logging import config_experiment_dir, init_logger, logger
  from openprompt.config import get_config, save_config_to_yaml
  from openprompt.plms import load_plm_from_config
  from openprompt.data_utils import load_dataset
  from openprompt.utils.cuda import model_to_device
label_desc: Use image node_id 3 for calling a global function with example usage: trainer(EXP_PATH, config, Processor, train_dataset, valid_dataset, test_dataset, resume, test, zero) and returns: res