class_docstr: Args:
      model (:obj:`PreTrainedModel`): The pre-trained language model for the current prompt-learning task.
      tokenizer (:obj:`PreTrainedTokenizer`): A tokenizer to appoint the vocabulary and the tokenization strategy.
      prompt_encoder_type (:obj:`str`): head above the embedding layer of new tokens. Can be ``lstm`` or ``mlp``.
      text (:obj:`Optional[List[str]]`, optional): manual template format. Defaults to None.
      placeholder_mapping (:obj:`dict`): A place holder to represent the original input text. Default to ``{'<text_a>': 'text_a', '<text_b>': 'text_b'}``
class_docstr_tok: ["Args",":","model","(",":","obj",":","`","PreTrainedModel","`",")",":","The","pre-trained","language","model","for","the","current","prompt-learning","task",".","tokenizer","(",":","obj",":","`","PreTrainedTokenizer","`",")",":","A","tokenizer","to","appoint","the","vocabulary","and","the","tokenization","strategy",".","prompt_encoder_type","(",":","obj",":","`","str","`",")",":","head","above","the","embedding","layer","of","new","tokens",".","Can","be","``","lstm","``","or","``","mlp","``",".","text","(",":","obj",":","`","Optional","[","List","[","str","]","]","`",",","optional",")",":","manual","template","format",".","Defaults","to","None",".","placeholder_mapping","(",":","obj",":","`","dict","`",")",":","A","place","holder","to","represent","the","original","input","text",".","Default","to","``","{","'","<","text_a",">","'",":","'text_a","'",",","'","<","text_b",">","'",":","'text_b","'","}","``"]
docstr: generate parameters needed for new tokens' embedding in P-tuning
docstr_tok: ["generate","parameters","needed","for","new","tokens","'","embedding","in","P-tuning"]
code: def generate_parameters(self) -> None:
      r"""
      generate parameters needed for new tokens' embedding in P-tuning
      """
      if self.num_soft_token == 0:
          return
      self.new_embedding = nn.Embedding(
          self.num_soft_token, self.embedding_size
      )
      self.new_ids = nn.Parameter(
          torch.LongTensor(list(range(self.num_soft_token))),
          requires_grad=False,
      )
      if self.prompt_encoder_type == "lstm":
          self.new_lstm_head = nn.LSTM(
              input_size=self.embedding_size,
              hidden_size=self.embedding_size,
              num_layers=2,
              bidirectional=True,
              batch_first=True,
          )
          self.new_mlp_head = nn.Sequential(
              nn.Linear(2 * self.embedding_size, self.embedding_size),
              nn.ReLU(),
              nn.Linear(self.embedding_size, self.embedding_size),
          )
      elif self.prompt_encoder_type == "mlp":
          self.new_mlp_head = nn.Sequential(
              nn.Linear(self.embedding_size, self.embedding_size),
              nn.ReLU(),
              nn.Linear(self.embedding_size, self.embedding_size),
          )
      else:
          raise ValueError("unknown prompt_enocder_type")
  
file_path: OpenPrompt/openprompt/prompts/ptuning_prompts.py
imports: from openprompt.data_utils import InputFeatures
  import os
  import torch
  from torch import nn
  from typing import *
  from transformers import PreTrainedModel
  from transformers.tokenization_utils import PreTrainedTokenizer
  from openprompt.prompts import MixedTemplate
label_desc: Use image node_id 3 for calling the PtuningTemplate obj's underlying member method code with example usage: obj.generate_parameters() without return types