class_docstr: The prompt encoder network that is used to generate the virtual token embeddings for p-tuning.
  
  Args:
      config ([`PromptEncoderConfig`]): The configuration of the prompt encoder.
  
  Example:
  
  ```py
  >>> from peft import PromptEncoder, PromptEncoderConfig
  
  >>> config = PromptEncoderConfig(
  ...     peft_type="P_TUNING",
  ...     task_type="SEQ_2_SEQ_LM",
  ...     num_virtual_tokens=20,
  ...     token_dim=768,
  ...     num_transformer_submodules=1,
  ...     num_attention_heads=12,
  ...     num_layers=12,
  ...     encoder_reparameterization_type="MLP",
  ...     encoder_hidden_size=768,
  ... )
  
  >>> prompt_encoder = PromptEncoder(config)
  ```
  
  **Attributes**:
      - **embedding** (`torch.nn.Embedding`) -- The embedding layer of the prompt encoder.
      - **mlp_head** (`torch.nn.Sequential`) -- The MLP head of the prompt encoder if `inference_mode=False`.
      - **lstm_head** (`torch.nn.LSTM`) -- The LSTM head of the prompt encoder if `inference_mode=False` and
      `encoder_reparameterization_type="LSTM"`.
      - **token_dim** (`int`) -- The hidden embedding dimension of the base transformer model.
      - **input_size** (`int`) -- The input size of the prompt encoder.
      - **output_size** (`int`) -- The output size of the prompt encoder.
      - **hidden_size** (`int`) -- The hidden size of the prompt encoder.
      - **total_virtual_tokens** (`int`): The total number of virtual tokens of the
      prompt encoder.
      - **encoder_type** (Union[[`PromptEncoderReparameterizationType`], `str`]): The encoder type of the prompt
        encoder.
  
  
  Input shape: (`batch_size`, `total_virtual_tokens`)
  
  Output shape: (`batch_size`, `total_virtual_tokens`, `token_dim`)
code: def forward(self, indices):
      input_embeds = self.embedding(indices)
      if self.encoder_type == PromptEncoderReparameterizationType.LSTM:
          output_embeds = self.mlp_head(self.lstm_head(input_embeds)[0])
      elif self.encoder_type == PromptEncoderReparameterizationType.MLP:
          output_embeds = self.mlp_head(input_embeds)
      else:
          raise ValueError(
              "Prompt encoder type not recognized. Please use one of MLP (recommended) or LSTM."
          )
  
      return output_embeds
  
imports: import warnings
  import torch
  from .config import PromptEncoderConfig, PromptEncoderReparameterizationType
label_desc: Use image node_id 2 for calling the PromptEncoder obj's underlying member method code with example usage: obj.forward(indices) and returns: output_embeds