class_docstr: PromptDataLoader wraps the original dataset. The input data is firstly wrapped with the
  prompt's template, and then is tokenized by a wrapperd-tokenizer.
  
  Args:
      dataset (:obj:`Dataset` or :obj:`List`): Either a DatasetObject or a list containing the input examples.
      template (:obj:`Template`): A derived class of :obj:`Template`
      tokenizer (:obj:`PretrainedTokenizer`): The pretrained tokenizer.
      tokenizer_wrapper_class (:cls:`TokenizerWrapper`): The class of tokenizer wrapper.
      max_seq_length (:obj:`int`, optional): The max sequence length of the input ids. It's used to truncate sentences.
      batch_size (:obj:`int`, optional): The batch_size of data loader
      teacher_forcing (:obj:`bool`, optional): Whether to fill the mask with target text. Set to true in training generation model.
      decoder_max_length (:obj:`int`, optional): the decoder maximum length of an encoder-decoder model.
      predict_eos_token (:obj:`bool`, optional): Whether to predict the <eos> token. Suggest to set to true in generation.
      truncate_method (:obj:`bool`, optional): the truncate method to use. select from `head`, `tail`, `balanced`.
      kwargs  :Other kwargs that might be passed into a tokenizer wrapper.
class_docstr_tok: ["PromptDataLoader","wraps","the","original","dataset",".","The","input","data","is","firstly","wrapped","with","the","prompt","'s","template",",","and","then","is","tokenized","by","a","wrapperd-tokenizer",".","Args",":","dataset","(",":","obj",":","`","Dataset","`","or",":","obj",":","`","List","`",")",":","Either","a","DatasetObject","or","a","list","containing","the","input","examples",".","template","(",":","obj",":","`","Template","`",")",":","A","derived","class","of",":","obj",":","`","Template","`","tokenizer","(",":","obj",":","`","PretrainedTokenizer","`",")",":","The","pretrained","tokenizer",".","tokenizer_wrapper_class","(",":","cls",":","`","TokenizerWrapper","`",")",":","The","class","of","tokenizer","wrapper",".","max_seq_length","(",":","obj",":","`","int","`",",","optional",")",":","The","max","sequence","length","of","the","input","ids",".","It","'s","used","to","truncate","sentences",".","batch_size","(",":","obj",":","`","int","`",",","optional",")",":","The","batch_size","of","data","loader","teacher_forcing","(",":","obj",":","`","bool","`",",","optional",")",":","Whether","to","fill","the","mask","with","target","text",".","Set","to","true","in","training","generation","model",".","decoder_max_length","(",":","obj",":","`","int","`",",","optional",")",":","the","decoder","maximum","length","of","an","encoder-decoder","model",".","predict_eos_token","(",":","obj",":","`","bool","`",",","optional",")",":","Whether","to","predict","the","<","eos",">","token",".","Suggest","to","set","to","true","in","generation",".","truncate_method","(",":","obj",":","`","bool","`",",","optional",")",":","the","truncate","method","to","use",".","select","from","`","head","`",",","`","tail","`",",","`","balanced","`",".","kwargs",":","Other","kwargs","that","might","be","passed","into","a","tokenizer","wrapper","."]
code: def __init__(
      self,
      dataset: Union[Dataset, List],
      template: Template,
      tokenizer_wrapper: Optional[TokenizerWrapper] = None,
      tokenizer: PreTrainedTokenizer = None,
      tokenizer_wrapper_class=None,
      verbalizer: Optional[Verbalizer] = None,
      max_seq_length: Optional[str] = 512,
      batch_size: Optional[int] = 1,
      shuffle: Optional[bool] = False,
      teacher_forcing: Optional[bool] = False,
      decoder_max_length: Optional[int] = -1,
      predict_eos_token: Optional[bool] = False,
      truncate_method: Optional[str] = "tail",
      drop_last: Optional[bool] = False,
      **kwargs,
  ):
      assert hasattr(
          dataset, "__iter__"
      ), f"The dataset must have __iter__ method. dataset is {dataset}"
      assert hasattr(
          dataset, "__len__"
      ), f"The dataset must have __len__ method. dataset is {dataset}"
      self.raw_dataset = dataset
  
      self.wrapped_dataset = []
      self.tensor_dataset = []
      self.template = template
      self.verbalizer = verbalizer
      self.batch_size = batch_size
      self.shuffle = shuffle
      self.teacher_forcing = teacher_forcing
  
      if tokenizer_wrapper is None:
          if tokenizer_wrapper_class is None:
              raise RuntimeError(
                  "Either wrapped_tokenizer or tokenizer_wrapper_class should be specified."
              )
          if tokenizer is None:
              raise RuntimeError(
                  "No tokenizer specified to instantiate tokenizer_wrapper."
              )
  
          tokenizer_wrapper_init_keys = signature(
              tokenizer_wrapper_class.__init__
          ).args
          prepare_kwargs = {
              "max_seq_length": max_seq_length,
              "truncate_method": truncate_method,
              "decoder_max_length": decoder_max_length,
              "predict_eos_token": predict_eos_token,
              "tokenizer": tokenizer,
              **kwargs,
          }
  
          to_pass_kwargs = {
              key: prepare_kwargs[key]
              for key in prepare_kwargs
              if key in tokenizer_wrapper_init_keys
          }
          self.tokenizer_wrapper = tokenizer_wrapper_class(
              **to_pass_kwargs
          )
      else:
          self.tokenizer_wrapper = tokenizer_wrapper
  
      # check the satisfiability of each component
      assert hasattr(
          self.template, "wrap_one_example"
      ), "Your prompt has no function variable \
                                                           named wrap_one_example"
  
      # process
      self.wrap()
      self.tokenize()
  
      if self.shuffle:
          sampler = RandomSampler(self.tensor_dataset)
      else:
          sampler = None
  
      self.dataloader = DataLoader(
          self.tensor_dataset,
          batch_size=self.batch_size,
          sampler=sampler,
          collate_fn=InputFeatures.collate_fct,
          drop_last=drop_last,
      )
  
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 1 to create a new PromptDataLoader object from inherited base classes: object with example: obj = PromptDataLoader(dataset, template, tokenizer_wrapper, tokenizer, tokenizer_wrapper_class, verbalizer, max_seq_length, batch_size, shuffle, teacher_forcing, decoder_max_length, predict_eos_token, truncate_method, drop_last)