class_docstr: This is the implementation of knowledeagble verbalizer, which uses external knowledge to expand the set of label words.
  This class inherit the ``ManualVerbalizer`` class.
  
  Args:
      tokenizer (:obj:`PreTrainedTokenizer`): The tokenizer of the current pre-trained model to point out the vocabulary.
      classes (:obj:`classes`): The classes (or labels) of the current task.
      prefix (:obj:`str`, optional): The prefix string of the verbalizer.
      multi_token_handler (:obj:`str`, optional): The handling strategy for multiple tokens produced by the tokenizer.
      max_token_split (:obj:`int`, optional):
      verbalizer_lr (:obj:`float`, optional): The learning rate of the verbalizer optimization.
      candidate_frac (:obj:`float`, optional):
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 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","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 one token.
      """
      all_ids = []
      label_words = []
      # print([len(x) for x in self.label_words], flush=True)
      for words_per_label in self.label_words:
          ids_per_label = []
          words_keep_per_label = []
          for word in words_per_label:
              ids = self.tokenizer.encode(
                  word, add_special_tokens=False
              )
              if (
                  self.max_token_split > 0
                  and len(ids) > self.max_token_split
              ):
                  # in knowledgebale verbalizer, the labelwords may be very rare, so we may
                  # want to remove the label words which are not recogonized by tokenizer.
                  logger.warning(
                      "Word {} is split into {} (>{}) tokens: {}. Ignored.".format(
                          word,
                          len(ids),
                          self.max_token_split,
                          self.tokenizer.convert_ids_to_tokens(ids),
                      )
                  )
                  continue
              else:
                  words_keep_per_label.append(word)
                  ids_per_label.append(ids)
          label_words.append(words_keep_per_label)
          all_ids.append(ids_per_label)
      self.label_words = label_words
  
      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,
      )
      self.label_words_weights = nn.Parameter(
          torch.zeros(self.num_classes, max_num_label_words),
          requires_grad=True,
      )
      print(
          "##Num of label words for each label: {}".format(
              self.label_words_mask.sum(-1).cpu().tolist()
          ),
          flush=True,
      )
  
imports: import os
  from openprompt.prompts.manual_template import ManualTemplate
  from transformers.tokenization_utils import PreTrainedTokenizer
  from transformers.utils.dummy_pt_objects import PreTrainedModel
  from openprompt.data_utils import InputFeatures
  import re
  from openprompt.prompts.manual_verbalizer import ManualVerbalizer
  from typing import *
  import torch
  import torch.nn
  import torch.nn.functional
  from openprompt.utils.logging import logger
label_desc: Use image node_id 5 for calling the KnowledgeableVerbalizer obj's underlying member method code with example usage: obj.generate_parameters() without return types