class_docstr: ``PromptModel`` with generation loss calculation and generation utils integrated.
  
  
  Args:
      plm (:obj:`PretrainedModel`): A pre-traiend model you decide to use for generation, e.g. GPT.
      template (:obj:`Template`): A ``Template`` object you use to wrap the input text for classification, e.g. ``PrefixTuningTemplate``.
      tokenizer (:obj:`Tokenizer`): A ``Tokenizer`` of the current model.
      gen_config (:obj:`CfgNode`): The generation configs to pass into `GenerationMixin.generate <https://huggingface.co/transformers/_modules/transformers/generation_utils.html#GenerationMixin.generate>`_
      freeze_plm (:obj:`bool`): whether or not to freeze the pretrained language model
      plm_eval_mode (:obj:`bool`): this is a stronger freezing mode than freeze_plm, i.e. the dropout of the model is turned off. No matter whether the other part is set to train.
class_docstr_tok: ["``","PromptModel","``","with","generation","loss","calculation","and","generation","utils","integrated",".","Args",":","plm","(",":","obj",":","`","PretrainedModel","`",")",":","A","pre-traiend","model","you","decide","to","use","for","generation",",","e.g",".","GPT",".","template","(",":","obj",":","`","Template","`",")",":","A","``","Template","``","object","you","use","to","wrap","the","input","text","for","classification",",","e.g",".","``","PrefixTuningTemplate","``",".","tokenizer","(",":","obj",":","`","Tokenizer","`",")",":","A","``","Tokenizer","``","of","the","current","model",".","gen_config","(",":","obj",":","`","CfgNode","`",")",":","The","generation","configs","to","pass","into","`","GenerationMixin.generate","<","https",":","\/\/huggingface.co\/transformers\/_modules\/transformers\/generation_utils.html","#","GenerationMixin.generate",">","`","_","freeze_plm","(",":","obj",":","`","bool","`",")",":","whether","or","not","to","freeze","the","pretrained","language","model","plm_eval_mode","(",":","obj",":","`","bool","`",")",":","this","is","a","stronger","freezing","mode","than","freeze_plm",",","i.e",".","the","dropout","of","the","model","is","turned","off",".","No","matter","whether","the","other","part","is","set","to","train","."]
docstr: In generation process, it will use the plm's forward function.
  This is because, in the first step we will directly call the process_batch function to
  generate initial input with the template, after that the all template
  have been processed into the past_key_value,
  then we can use the normal generation function.
  In learning process, the forward is linked to ``_forward`` functions.
  in which the loss will be calculated for all the positions in the same time.
docstr_tok: ["In","generation","process",",","it","will","use","the","plm","'s","forward","function",".","This","is","because",",","in","the","first","step","we","will","directly","call","the","process_batch","function","to","generate","initial","input","with","the","template",",","after","that","the","all","template","have","been","processed","into","the","past_key_value",",","then","we","can","use","the","normal","generation","function",".","In","learning","process",",","the","forward","is","linked","to","``","_forward","``","functions",".","in","which","the","loss","will","be","calculated","for","all","the","positions","in","the","same","time","."]
code: def forward(self, *args, **kwargs):
      r"""In generation process, it will use the plm's forward function.
      This is because, in the first step we will directly call the process_batch function to
      generate initial input with the template, after that the all template
      have been processed into the past_key_value,
      then we can use the normal generation function.
      In learning process, the forward is linked to ``_forward`` functions.
      in which the loss will be calculated for all the positions in the same time.
      """
      if self.in_generation_function:
          return self.plm.forward(*args, **kwargs)
      else:
          return self._forward(*args, **kwargs)
  
imports: from pickle import FALSE
  from torch.utils.data.sampler import RandomSampler
  from transformers.configuration_utils import PretrainedConfig
  from transformers.generation_utils import GenerationMixin
  import torch
  import torch.nn
  from torch.utils.data import Dataset
  from typing import *
  from openprompt.data_utils import InputExample, InputFeatures
  from torch.utils.data._utils.collate import default_collate
  from tqdm.std import tqdm
  from transformers.tokenization_utils import PreTrainedTokenizer
  from transformers.utils.dummy_pt_objects import PreTrainedModel
  from openprompt.plms.utils import TokenizerWrapper
  from openprompt.prompt_base import Template, Verbalizer
  from collections import defaultdict
  from openprompt.utils import round_list, signature
  import numpy
  from torch.utils.data import DataLoader
  from yacs.config import CfgNode
  from openprompt.utils.logging import logger
  from transformers import AdamW, get_linear_schedule_with_warmup
label_desc: Use image node_id 8 for calling the PromptForGeneration obj's underlying member method code with example usage: obj.forward() and returns: self, self