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: 1) Process vocab logits of each `<mask>` into label logits of each `<mask>`
  
  2) Combine these logits into a single label logits of the whole task
  
  Args:
      logits (:obj:`torch.Tensor`): vocab logits of each `<mask>` (shape: `[batch_size, num_masks, vocab_size]`)
  
  Returns:
      :obj:`torch.Tensor`: logits (label logits of whole task (shape: `[batch_size, label_size of the whole task]`))
docstr_tok: ["1",")","Process","vocab","logits","of","each","`","<","mask",">","`","into","label","logits","of","each","`","<","mask",">","`","2",")","Combine","these","logits","into","a","single","label","logits","of","the","whole","task","Args",":","logits","(",":","obj",":","`","torch.Tensor","`",")",":","vocab","logits","of","each","`","<","mask",">","`","(","shape",":","`","[","batch_size",",","num_masks",",","vocab_size","]","`",")","Returns",":",":","obj",":","`","torch.Tensor","`",":","logits","(","label","logits","of","whole","task","(","shape",":","`","[","batch_size",",","label_size","of","the","whole","task","]","`",")",")"]
code: def process_logits(
      self,
      logits: torch.Tensor,  # [batch_size, num_masks, vocab_size]
      batch: Union[Dict, InputFeatures],
      **kwargs,
  ):
      """
      1) Process vocab logits of each `<mask>` into label logits of each `<mask>`
  
      2) Combine these logits into a single label logits of the whole task
  
      Args:
          logits (:obj:`torch.Tensor`): vocab logits of each `<mask>` (shape: `[batch_size, num_masks, vocab_size]`)
  
      Returns:
          :obj:`torch.Tensor`: logits (label logits of whole task (shape: `[batch_size, label_size of the whole task]`))
      """
      each_logits = [  # logits of each verbalizer
          self.verbalizers[i].process_logits(
              logits=logits[:, i, :], batch=batch, **kwargs
          )
          for i in range(self.num_masks)
      ]  # num_masks * [batch_size, label_size of the corresponding mask]
  
      label_logits = [
          logits[:, self.label_mappings[j]]
          for j, logits in enumerate(each_logits)
      ]
  
      logsoftmax = nn.functional.log_softmax(sum(label_logits), dim=-1)
  
      if "label" in batch:  # TODO not an elegant solution
          each_logsoftmax = [  # (logits of each label) of each mask
              nn.functional.log_softmax(logits, dim=-1)[
                  :, self.label_mappings[j]
              ]
              for j, logits in enumerate(each_logits)
          ]  # num_masks * [batch_size, label_size of the whole task]
  
          return logsoftmax + sum(each_logsoftmax) / len(
              each_logits
          )  # [batch_size, label_size of the whole task]
  
      return logsoftmax
  
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 3 for calling the PTRVerbalizer obj's underlying member method code with example usage: obj.process_logits(logits, batch) and returns: logsoftmax, unknown