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: The parents class's ``_update_model_kwargs_for_generation`` method will
  add ``past_key_values`` to model_kwargs, and update ``token_type_ids``, and ``attention_mask_ids``.
  
  In case some of the model_kwargs are modified in the prepare_inputs_for_generation function
  and should be used as the subsequent model_kwargs, we update these kwargs before the parent class
  call.
  
  Other updates should be added here after the parent's function call.
  
  Args:
      outputs (:obj:`torch.Tensor`):
      is_encoder_decoder (:obj:`bool`, defaults to False):
docstr_tok: ["The","parents","class","'s","``","_update_model_kwargs_for_generation","``","method","will","add","``","past_key_values","``","to","model_kwargs",",","and","update","``","token_type_ids","``",",","and","``","attention_mask_ids","``",".","In","case","some","of","the","model_kwargs","are","modified","in","the","prepare_inputs_for_generation","function","and","should","be","used","as","the","subsequent","model_kwargs",",","we","update","these","kwargs","before","the","parent","class","call",".","Other","updates","should","be","added","here","after","the","parent","'s","function","call",".","Args",":","outputs","(",":","obj",":","`","torch.Tensor","`",")",":","is_encoder_decoder","(",":","obj",":","`","bool","`",",","defaults","to","False",")",":"]
code: def _update_model_kwargs_for_generation(
      self,
      outputs,
      model_kwargs: Dict[str, Any],
      is_encoder_decoder: bool = False,
  ) -> Dict[str, Any]:
      r"""The parents class's ``_update_model_kwargs_for_generation`` method will
      add ``past_key_values`` to model_kwargs, and update ``token_type_ids``, and ``attention_mask_ids``.
  
      In case some of the model_kwargs are modified in the prepare_inputs_for_generation function
      and should be used as the subsequent model_kwargs, we update these kwargs before the parent class
      call.
  
      Other updates should be added here after the parent's function call.
  
      Args:
          outputs (:obj:`torch.Tensor`):
          is_encoder_decoder (:obj:`bool`, defaults to False):
      """
      if self.generate_ith_token == 0:
          for key in self.last_model_inputs:
              if key in model_kwargs:
                  model_kwargs[key] = self.last_model_inputs[key]
      model_kwargs = super()._update_model_kwargs_for_generation(
          outputs=outputs,
          model_kwargs=model_kwargs,
          is_encoder_decoder=is_encoder_decoder,
      )
      self.generate_ith_token += 1
      return model_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 14 for calling the PromptForGeneration obj's underlying member method code with example usage: obj._update_model_kwargs_for_generation(outputs, model_kwargs, is_encoder_decoder) and returns: model_kwargs