class_docstr: In `PTR <https://arxiv.org/pdf/2105.11259.pdf>`_, each prompt has more than one ``<mask>`` tokens.
  Different ``<mask>`` tokens have different label words.
  The final label is predicted jointly by these label words using logic rules.
  
  Args:
      tokenizer (:obj:`PreTrainedTokenizer`): A tokenizer to appoint the vocabulary and the tokenization strategy.
      classes (:obj:`Sequence[str]`): A sequence of classes that need to be projected.
      label_words (:obj:`Union[Sequence[Sequence[str]], Mapping[str, Sequence[str]]]`, optional): The label words that are projected by the labels.
class_docstr_tok: ["In","`","PTR","<","https",":","\/\/arxiv.org\/pdf\/2105.11259.pdf",">","`","_",",","each","prompt","has","more","than","one","``","<","mask",">","``","tokens",".","Different","``","<","mask",">","``","tokens","have","different","label","words",".","The","final","label","is","predicted","jointly","by","these","label","words","using","logic","rules",".","Args",":","tokenizer","(",":","obj",":","`","PreTrainedTokenizer","`",")",":","A","tokenizer","to","appoint","the","vocabulary","and","the","tokenization","strategy",".","classes","(",":","obj",":","`","Sequence","[","str","]","`",")",":","A","sequence","of","classes","that","need","to","be","projected",".","label_words","(",":","obj",":","`","Union","[","Sequence","[","Sequence","[","str","]","]",",","Mapping","[","str",",","Sequence","[","str","]","]","]","`",",","optional",")",":","The","label","words","that","are","projected","by","the","labels","."]
docstr: Prepare One2oneVerbalizer for each `<mask>` separately
docstr_tok: ["Prepare","One2oneVerbalizer","for","each","`","<","mask",">","`","separately"]
code: def on_label_words_set(self):
      """
      Prepare One2oneVerbalizer for each `<mask>` separately
      """
      super().on_label_words_set()
  
      self.num_masks = len(self.label_words[0])
      for words in self.label_words:
          if len(words) != self.num_masks:
              raise ValueError(
                  "number of mask tokens for different classes are not consistent"
              )
      self.sub_labels = [
          list(set([words[i] for words in self.label_words]))
          for i in range(self.num_masks)
      ]  # [num_masks, label_size of the corresponding mask]
  
      self.verbalizers = nn.ModuleList(
          [
              One2oneVerbalizer(
                  tokenizer=self.tokenizer,
                  label_words=labels,
                  post_log_softmax=False,
              )
              for labels in self.sub_labels
          ]
      )  # [num_masks]
  
      self.label_mappings = nn.Parameter(
          torch.LongTensor(
              [
                  [labels.index(words[j]) for words in self.label_words]
                  for j, labels in enumerate(self.sub_labels)
              ]
          ),
          requires_grad=False,
      )
  
file_path: OpenPrompt/openprompt/prompts/ptr_prompts.py
imports: import json
  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 import Verbalizer
  from openprompt.prompts import One2oneVerbalizer, PtuningTemplate
label_desc: Use image node_id 2 for calling the PTRVerbalizer obj's underlying member method code with example usage: obj.on_label_words_set() without return types