class_docstr: Base class for all the verbalizers.
  
  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.
class_docstr_tok: ["Base","class","for","all","the","verbalizers",".","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","."]
docstr: Load the predefined label words from verbalizer file.
  Currently support three types of file format:
  1. a .jsonl or .json file, in which is a single verbalizer
  in dict format.
  2. a .jsonal or .json file, in which is a list of verbalizers in dict format
  3.  a .txt or a .csv file, in which is the label words of a class are listed in line,
  separated by commas. Begin a new verbalizer by an empty line.
  This format is recommended when you don't know the name of each class.
  
  The details of verbalizer format can be seen in :ref:`How_to_write_a_verbalizer`.
  
  Args:
      path (:obj:`str`): The path of the local template file.
      choice (:obj:`int`): The choice of verbalizer in a file containing
                       multiple verbalizers.
  
  Returns:
      Template : `self` object
code: def from_file(self, path: str, choice: Optional[int] = 0):
      r"""Load the predefined label words from verbalizer file.
      Currently support three types of file format:
      1. a .jsonl or .json file, in which is a single verbalizer
      in dict format.
      2. a .jsonal or .json file, in which is a list of verbalizers in dict format
      3.  a .txt or a .csv file, in which is the label words of a class are listed in line,
      separated by commas. Begin a new verbalizer by an empty line.
      This format is recommended when you don't know the name of each class.
  
      The details of verbalizer format can be seen in :ref:`How_to_write_a_verbalizer`.
  
      Args:
          path (:obj:`str`): The path of the local template file.
          choice (:obj:`int`): The choice of verbalizer in a file containing
                           multiple verbalizers.
  
      Returns:
          Template : `self` object
      """
      if path.endswith(".txt") or path.endswith(".csv"):
          with open(path, "r") as f:
              lines = f.readlines()
              label_words_all = []
              label_words_single_group = []
              for line in lines:
                  line = line.strip().strip(" ")
                  if line == "":
                      if len(label_words_single_group) > 0:
                          label_words_all.append(
                              label_words_single_group
                          )
                      label_words_single_group = []
                  else:
                      label_words_single_group.append(line)
              if (
                  len(label_words_single_group) > 0
              ):  # if no empty line in the last
                  label_words_all.append(label_words_single_group)
              if choice >= len(label_words_all):
                  raise RuntimeError(
                      "choice {} exceed the number of verbalizers {}".format(
                          choice, len(label_words_all)
                      )
                  )
  
              label_words = label_words_all[choice]
              label_words = [
                  label_words_per_label.strip().split(",")
                  for label_words_per_label in label_words
              ]
  
      elif path.endswith(".jsonl") or path.endswith(".json"):
          with open(path, "r") as f:
              label_words_all = json.load(f)
              # if it is a file containing multiple verbalizers
              if isinstance(label_words_all, list):
                  if choice >= len(label_words_all):
                      raise RuntimeError(
                          "choice {} exceed the number of verbalizers {}".format(
                              choice, len(label_words_all)
                          )
                      )
                  label_words = label_words_all[choice]
              elif isinstance(label_words_all, dict):
                  label_words = label_words_all
                  if choice > 0:
                      logger.warning(
                          "Choice of verbalizer is 1, but the file  \
                          only contains one verbalizer."
                      )
  
      self.label_words = label_words
      if self.num_classes is not None:
          num_classes = len(self.label_words)
          assert (
              num_classes == self.num_classes
          ), "number of classes in the verbalizer file\
                                              does not match the predefined num_classes."
      return self
  
imports: from abc import abstractmethod
  import json
  from transformers.file_utils import ModelOutput
  from openprompt.config import convert_cfg_to_dict
  from transformers.utils.dummy_pt_objects import PreTrainedModel
  from openprompt.utils.utils import signature
  from yacs.config import CfgNode
  from openprompt.data_utils import InputFeatures, InputExample
  import torch
  import torch.nn
  from typing import *
  from transformers.tokenization_utils import PreTrainedTokenizer
  from openprompt.utils.logging import logger
  import numpy
  import torch.nn.functional
label_desc: Use image node_id 18 for calling the Verbalizer obj's underlying member method code with example usage: obj.from_file(path, choice) and returns: self