code: def __init__(
      self,
      input_case: str,
      cache_dir: str = None,
      overwrite_cache: bool = False,
      deterministic: bool = True,
  ):
      super().__init__(
          name="tokenize_and_classify",
          kind="classify",
          deterministic=deterministic,
      )
  
      far_file = None
      if cache_dir is not None and cache_dir != "None":
          os.makedirs(cache_dir, exist_ok=True)
          far_file = os.path.join(
              cache_dir,
              f"_{input_case}_en_tn_{deterministic}_deterministic.far",
          )
      if not overwrite_cache and far_file and os.path.exists(far_file):
          self.fst = pynini.Far(far_file, mode="r")[
              "tokenize_and_classify"
          ]
          logging.info(f"ClassifyFst.fst was restored from {far_file}.")
      else:
          logging.info(f"Creating ClassifyFst grammars.")
  
          punctuation = PunctuationFst(deterministic=deterministic)
          punct_graph = punctuation.fst
          word_graph = WordFst(
              deterministic=deterministic, punctuation=punctuation
          ).fst
          electonic_graph = ElectronicFst(
              cardinal=None, deterministic=deterministic
          ).fst
  
          classify = pynutil.add_weight(
              electonic_graph, 1.1
          ) | pynutil.add_weight(word_graph, 100)
  
          punct = (
              pynutil.insert("tokens { ")
              + pynutil.add_weight(punct_graph, weight=2.1)
              + pynutil.insert(" }")
          )
          punct = pynini.closure(
              pynini.compose(
                  pynini.closure(NEMO_WHITE_SPACE, 1),
                  delete_extra_space,
              )
              | (pynutil.insert(" ") + punct),
              1,
          )
          token = (
              pynutil.insert("tokens { ")
              + classify
              + pynutil.insert(" }")
          )
          token_plus_punct = (
              pynini.closure(punct + pynutil.insert(" "))
              + token
              + pynini.closure(pynutil.insert(" ") + punct)
          )
  
          graph = (
              token_plus_punct
              + pynini.closure(
                  (
                      pynini.compose(
                          pynini.closure(NEMO_WHITE_SPACE, 1),
                          delete_extra_space,
                      )
                      | (
                          pynutil.insert(" ")
                          + punct
                          + pynutil.insert(" ")
                      )
                  )
                  + token_plus_punct
              ).optimize()
          )
  
          graph = delete_space + graph + delete_space
          graph |= punct
  
          self.fst = graph.optimize()
  
          if far_file:
              generator_main(
                  far_file, {"tokenize_and_classify": self.fst}
              )
              logging.info(
                  f"ClassifyFst grammars are saved to {far_file}."
              )
  
imports: import os
  from nemo.utils import logging
label_desc: Use image node_id 1 to create a new ClassifyFst object from inherited base classes: GraphFst with example: obj = ClassifyFst(input_case, cache_dir, overwrite_cache, deterministic)