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.
docstr: In basic manual template, the parameters are generated from label words directly.
  In this implementation, the label_words should not be tokenized into more than one token.
docstr_tok: ["In","basic","manual","template",",","the","parameters","are","generated","from","label","words","directly",".","In","this","implementation",",","the","label_words","should","not","be","tokenized","into","more","than","one","token","."]
code: def generate_parameters(self) -> List:
      r"""In basic manual template, the parameters are generated from label words directly.
      In this implementation, the label_words should not be tokenized into more than one token.
      """
      all_ids = []
      for words_per_label in self.label_words:
          ids_per_label = []
          for word in words_per_label:
              ids = self.tokenizer.encode(
                  word, add_special_tokens=False
              )
              ids_per_label.append(ids)
          all_ids.append(ids_per_label)
  
      max_len = max(
          [
              max([len(ids) for ids in ids_per_label])
              for ids_per_label in all_ids
          ]
      )
      max_num_label_words = max(
          [len(ids_per_label) for ids_per_label in all_ids]
      )
      words_ids_mask = torch.zeros(max_num_label_words, max_len)
      words_ids_mask = [
          [
              [1] * len(ids) + [0] * (max_len - len(ids))
              for ids in ids_per_label
          ]
          + [[0] * max_len] * (max_num_label_words - len(ids_per_label))
          for ids_per_label in all_ids
      ]
      words_ids = [
          [ids + [0] * (max_len - len(ids)) for ids in ids_per_label]
          + [[0] * max_len] * (max_num_label_words - len(ids_per_label))
          for ids_per_label in all_ids
      ]
  
      words_ids_tensor = torch.tensor(words_ids)
      words_ids_mask = torch.tensor(words_ids_mask)
      self.label_words_ids = nn.Parameter(
          words_ids_tensor, requires_grad=False
      )
      self.words_ids_mask = nn.Parameter(
          words_ids_mask, requires_grad=False
      )  # A 3-d mask
      self.label_words_mask = nn.Parameter(
          torch.clamp(words_ids_mask.sum(dim=-1), max=1),
          requires_grad=False,
      )
  
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 5 for calling the ProtoVerbalizer obj's underlying member method code with example usage: obj.generate_parameters() without return types