class_docstr: This verbalizer is useful when the label prediction is better defined by a piece of input.
  For example, in correference resolution, the tgt_text is a proper noun mentioned in the text.
  There is no fixed mapping between a class label and its label words. This verbalizer
  can be used as verbalizer of ``COPA`` and ``WSC`` datasets in SuperGlue.
  
  This verbalizer is especially powerful when combined with
  `All NLP Tasks Are Generation Tasks <https://arxiv.org/abs/2103.10360>`_ Paradigm (Also see
  `Crossfit <https://arxiv.org/abs/2104.08835>`_). It can make any piece of text the tgt_text. The tgt_text will then be filled in the `{"mask"}`.
  
  For example, when label word is ``"good"``, the tgt_text is ``"good"``;
  
  when label word is ``{"text":"good"}``, the tgt_text is also ``"good"``;
  
  when label word is ``{"meta":"choice1"}``, the tgt_text is the ``"meta['choice1']"`` field of the ``InputExample``;
  
  when label word is ``{"meta":"choice1"} {"placeholder", "text_a"} .``, the tgt_text is the ``"meta['choice1']"`` field of the ``InputExample``,
  followed by ``text_a`` field of the ``InputExample``, and then a ``'.'``;
  
  A use case can be seen in `Tutorial 4.1 <https://github.com/thunlp/OpenPrompt/blob/main/tutorial/4.1_all_tasks_are_generation.py>`_
  
  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.
      prefix (:obj:`str`, optional): The prefix string of the verbalizer (used in PLMs like RoBERTa, which is sensitive to prefix space)
      is_rule (:obj:`bool`, optional): When the verbalizer use the rule syntax of MixTemplate.
      label_words (:obj:`dict`, optional): The label words of the generation verbalizer
  
  Example:
  To use this verbalizer to train the T5 model to predict answer and explanation using two masks.
  
  When the template (Defined by :obj:`MixedTemplate`) is:
  >>> input_example = InputExample(text_a = "Can fish run?", meta={"answer":"no", "explanation": "The fish have no legs"}, label=0)
  >>> template = "{'placeholder':'text_a'} answer: {'mask'} explanation: {'mask'}"
  
  The verbalizer can be:
  >>> label_words = {0:["no", "{'meta':'explanation'}"], 1:["yes", "{'meta':'explanation'}"]}
  >>> verbalizer = GenerationVerbalizer(tokenizer, classes=None, is_rule=True, label_words=label_words)
docstr: Process the text into the label words (sometimes a function) according to the syntax of MixedTemplate
docstr_tok: ["Process","the","text","into","the","label","words","(","sometimes","a","function",")","according","to","the","syntax","of","MixedTemplate"]
code: def on_label_words_set(self):
      r"""
      Process the text into the label words (sometimes a function) according to the syntax of MixedTemplate
      """
      if isinstance(self.label_words[0], list):
          self.label_words = [x[0] for x in self.label_words]
  
      if self.is_rule:
          for id, label_word in enumerate(self.label_words):
              try:
                  d = self.parse_text(label_word)
              except:
                  raise RuntimeError(
                      f"is_rule={self.is_rule} but label_word: {label_word} can't be converted to object."
                  )
              self.label_words[id] = partial(
                  lambda x, text: self.incorporate_text_example(
                      text, x
                  ),
                  text=d,
              )
  
imports: from functools import partial
  import json
  from openprompt.data_utils.utils import InputExample
  from transformers.tokenization_utils import PreTrainedTokenizer
  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
  from openprompt.utils.crossfit_metrics import *
  import re
label_desc: Use image node_id 3 for calling the GenerationVerbalizer obj's underlying member method code with example usage: obj.on_label_words_set() without return types