class_docstr: The implementation of the prototypical verbalizer in `Prototypical Verbalizer for Prompt-based Few-shot Tuning <https://arxiv.org/pdf/2104.08691v1.pdf>`_ This class is inherited from the :obj:`Verbalizer` class.
  
  Args:
      tokenizer (:obj:`PreTrainedTokenizer`): The tokenizer of the current pre-trained model to point out the vocabulary.
      classes (:obj:`List[Any]`): The classes (or labels) of the current task.
      label_words (:obj:`Union[List[str], List[List[str]], Dict[List[str]]]`, optional): The label words that are projected by the labels.
      prefix (:obj:`str`, optional): The prefix string of the verbalizer (used in PLMs like RoBERTa, which is sensitive to prefix space)
      multi_token_handler (:obj:`str`, optional): The handling strategy for multiple tokens produced by the tokenizer.
      post_log_softmax (:obj:`bool`, optional): Whether to apply log softmax post processing on label_logits. Default to True.
      lr: (:obj:`float`, optional): The learning rate for prototypes.
      mid_dim: (:obj:`int`, optional): The dimension of prototype embeddings.
      epochs: (:obj:`int`, optional): The training epochs of prototypes.
      multi_verb (:obj:`str`, optional): `multi` to ensemble with manual verbalizers, `proto` to use only ProtoVerb.
code: def __init__(
      self,
      tokenizer: Optional[PreTrainedTokenizer],
      model: Optional[PreTrainedModel],
      classes: Optional[List] = None,
      num_classes: Optional[Sequence[str]] = None,
      label_words: Optional[
          Union[Sequence[str], Mapping[str, str]]
      ] = None,
      prefix: Optional[str] = " ",
      multi_token_handler: Optional[str] = "first",
      post_log_softmax: Optional[bool] = True,
      lr: Optional[float] = 1e-3,
      mid_dim: Optional[int] = 64,
      epochs: Optional[int] = 5,
      multi_verb: Optional[str] = "multi",
  ):
      super().__init__(
          tokenizer=tokenizer, num_classes=num_classes, classes=classes
      )
      self.prefix = prefix
      self.multi_token_handler = multi_token_handler
      self.post_log_softmax = post_log_softmax
      self.multi_verb = multi_verb
      self.lr = lr
      self.mid_dim = mid_dim
      self.epochs = epochs
      self.trained = False
  
      self.hidden_dims = model.config.hidden_size
  
      self.head = torch.nn.Linear(
          self.hidden_dims, self.mid_dim, bias=False
      )
  
      if (
          label_words is not None
      ):  # use label words as an initialization
          self.label_words = label_words
      w = torch.empty((self.num_classes, self.mid_dim))
      nn.init.xavier_uniform_(w)
      self.proto = nn.Parameter(w, requires_grad=True)
      self.optimizer = torch.optim.Adam(
          self.group_parameters_proto, lr=self.lr
      )
  
imports: from inspect import Parameter
  import json
  from os import stat
  from transformers.file_utils import ModelOutput
  from transformers.tokenization_utils import PreTrainedTokenizer
  from transformers.utils.dummy_pt_objects import PreTrainedModel
  from yacs.config import CfgNode
  from openprompt.data_utils import InputFeatures
  import re
  from openprompt import Verbalizer
  from typing import *
  import torch
  import torch.nn
  import torch.nn.functional
  from openprompt.utils.logging import logger
  import copy
  from transformers.modeling_outputs import CausalLMOutputWithCrossAttentions, Seq2SeqLMOutput, MaskedLMOutput
  from transformers.models.t5 import T5ForConditionalGeneration
label_desc: Use image node_id 1 to create a new ProtoVerbalizer object from inherited base classes: Verbalizer with example: obj = ProtoVerbalizer(tokenizer, model, classes, num_classes, label_words, prefix, multi_token_handler, post_log_softmax, lr, mid_dim, epochs, multi_verb)