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: Left shift the label, and make label of the positions that are
  not loss position to -100, which is the ignore index in pytorch's
  loss function.
  
  Args:
      logits (:obj:`torch.Tensor`):
      batch (:obj:`InputFeatures`): The input features of batchified data sequences.
  
  Returns:
      shift_logits (:obj:`torch.Tensor`):
      shift_input_ids (:obj:`List[int]`):
docstr_tok: ["Left","shift","the","label",",","and","make","label","of","the","positions","that","are","not","loss","position","to","-100",",","which","is","the","ignore","index","in","pytorch's","loss","function",".","Args",":","logits","(",":","obj",":","`","torch.Tensor","`",")",":","batch","(",":","obj",":","`","InputFeatures","`",")",":","The","input","features","of","batchified","data","sequences",".","Returns",":","shift_logits","(",":","obj",":","`","torch.Tensor","`",")",":","shift_input_ids","(",":","obj",":","`","List","[","int","]","`",")",":"]
code: def shift_logits_and_labels(self, logits, loss_ids, reference_ids):
      r"""
      Left shift the label, and make label of the positions that are
      not loss position to -100, which is the ignore index in pytorch's
      loss function.
  
      Args:
          logits (:obj:`torch.Tensor`):
          batch (:obj:`InputFeatures`): The input features of batchified data sequences.
  
      Returns:
          shift_logits (:obj:`torch.Tensor`):
          shift_input_ids (:obj:`List[int]`):
  
      """
  
      shift_logits = logits[..., :-1, :].contiguous()
      shift_loss_ids = loss_ids[..., 1:].contiguous()
      shift_input_ids = reference_ids[..., 1:].contiguous()
      shift_input_ids = torch.where(
          shift_loss_ids > 0, shift_input_ids, -100
      )
      return shift_logits, shift_input_ids
  
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 7 for calling the PromptForGeneration obj's underlying member method code with example usage: obj.shift_logits_and_labels(logits, loss_ids, reference_ids) and returns: shift_logits,  shift_input_ids