class_docstr: The Mixed Template class defined by a string of `text`. See more examples in the `tutorial <https://github.com/thunlp/OpenPrompt/blob/ca27491101df0108a8dd753e5b1e79bf591f65d3/tutorial/1.1_mixed_template.py>`_.
  
  Args:
      model (:obj:`PreTrainedModel`): The pre-trained language model for the current prompt-learning task.
      tokenizer (:obj:`PreTrainedTokenizer`): A tokenizer to appoint the vocabulary and the tokenization strategy.
      text (:obj:`Optional[List[str]]`, optional): manual template format. Defaults to None.
class_docstr_tok: ["The","Mixed","Template","class","defined","by","a","string","of","`","text","`",".","See","more","examples","in","the","`","tutorial","<","https",":","\/\/github.com\/thunlp\/OpenPrompt\/blob\/ca27491101df0108a8dd753e5b1e79bf591f65d3\/tutorial\/1.1_mixed_template.py",">","`","_",".","Args",":","model","(",":","obj",":","`","PreTrainedModel","`",")",":","The","pre-trained","language","model","for","the","current","prompt-learning","task",".","tokenizer","(",":","obj",":","`","PreTrainedTokenizer","`",")",":","A","tokenizer","to","appoint","the","vocabulary","and","the","tokenization","strategy",".","text","(",":","obj",":","`","Optional","[","List","[","str","]","]","`",",","optional",")",":","manual","template","format",".","Defaults","to","None","."]
code: def parse_text(self, text: str) -> List[Dict]:
      parsed = []
      i = 0
      while i < len(text):
          d = {
              "add_prefix_space": " "
              if (i > 0 and text[i - 1] == " ")
              else ""
          }
          while i < len(text) and text[i] == " ":
              d["add_prefix_space"] = " "
              i = i + 1
          if i == len(text):
              break
  
          if text[i] != self.mixed_token_start:
              j = i + 1
              while j < len(text):
                  if text[j] == self.mixed_token_start:
                      break
                  j = j + 1
              d["text"] = text[i:j].rstrip(" ")
              i = j
  
          else:
              j = i + 1
              mixed_token_cnt = 1  # { {} {} } nested support
              while j < len(text):
                  if text[j] == self.mixed_token_end:
                      mixed_token_cnt -= 1
                      if mixed_token_cnt == 0:
                          break
                  elif text[j] == self.mixed_token_start:
                      mixed_token_cnt += 1
                  j = j + 1
              if j == len(text):
                  raise ValueError(
                      f"mixed_token_start {self.mixed_token_start} at position {i} has no corresponding mixed_token_end {self.mixed_token_end}"
                  )
              dict_str = "{" + text[i + 1 : j] + "}"
              try:
                  val = eval(dict_str)
                  if isinstance(val, set):
                      val = {k: None for k in val}
                  d.update(val)
              except:
                  import traceback
  
                  print(traceback.format_exc())
                  print(f"syntax error in {dict_str}")
                  exit()
              i = j + 1
  
          parsed.append(d)
  
      return parsed
  
file_path: OpenPrompt/openprompt/prompts/mixed_template.py
imports: import os
  import string
  from openprompt.utils.logging import logger
  from openprompt.data_utils.utils import InputExample, InputFeatures
  from typing import *
  from transformers import PreTrainedModel
  from transformers.tokenization_utils import PreTrainedTokenizer
  from openprompt import Template
  import torch
  from torch import nn
  from sys import exit
label_desc: Use image node_id 4 for calling the MixedTemplate obj's underlying member method code with example usage: obj.parse_text(text) and returns: parsed