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: Convert input_ids to inputs_embeds
  for normal tokens, use the embedding layer of PLM
  for new tokens, use a brand new embedding layer, with MLP or LSTM head
docstr_tok: ["Convert","input_ids","to","inputs_embeds","for","normal","tokens",",","use","the","embedding","layer","of","PLM","for","new","tokens",",","use","a","brand","new","embedding","layer",",","with","MLP","or","LSTM","head"]
code: def process_batch(
      self, batch: Union[Dict, InputFeatures]
  ) -> Union[Dict, InputFeatures]:
      r"""
      Convert input_ids to inputs_embeds
      for normal tokens, use the embedding layer of PLM
      for new tokens, use a brand new embedding layer, with MLP or LSTM head
      """
      inputs_embeds = self.raw_embedding(batch["input_ids"])
  
      if self.num_soft_token != 0:
          new_embeds = self.new_embedding(self.new_ids).unsqueeze(0)
          if self.prompt_encoder_type == "lstm":
              new_embeds = self.new_lstm_head(new_embeds)[0]
          new_embeds = self.new_mlp_head(new_embeds)
  
          replace_idxs = torch.nonzero(
              batch["soft_token_ids"] > 0
          ).view(-1, self.num_soft_token, 2)
          for b in range(replace_idxs.shape[0]):
              for i in range(self.num_soft_token):
                  inputs_embeds[b][replace_idxs[b][i][1]] = new_embeds[
                      0
                  ][i]
  
      batch["input_ids"] = None
      batch["inputs_embeds"] = inputs_embeds
      return batch
  
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 4 for calling the PtuningTemplate obj's underlying member method code with example usage: obj.process_batch(batch) and returns: batch