docstr: Encodes text that has already been run through G2Pr.
  Called for encoding to tokens after text preprocessing and G2P.
  
  Args:
      g2p_text: G2P's output, could be a mixture of Chinese phonemes and English letters.
      raw_text: original raw input
docstr_tok: ["Encodes","text","that","has","already","been","run","through","G2Pr",".","Called","for","encoding","to","tokens","after","text","preprocessing","and","G2P",".","Args",":","g2p_text",":","G2P","'s","output",",","could","be","a","mixture","of","Chinese","phonemes","and","English","letters",".","raw_text",":","original","raw","input"]
code: def encode_from_g2p(
      self, g2p_text: List[str], raw_text: Optional[str] = None
  ):
      """
      Encodes text that has already been run through G2Pr.
      Called for encoding to tokens after text preprocessing and G2P.
  
      Args:
          g2p_text: G2P's output, could be a mixture of Chinese phonemes and English letters.
          raw_text: original raw input
      """
      ps, space, tokens = [], self.tokens[self.space], set(self.tokens)
      for p in g2p_text:  # noqa
          # Add space if last one isn't one
          if p == space and len(ps) > 0 and ps[-1] != space:
              ps.append(p)
          # Add next phoneme or tone or ascii letter or apostrophe.
          elif (
              p.isalnum()
              or p == "'"
              or p
              in self.phoneme_list
              + self.tone_list
              + self.ascii_letter_list
          ) and p in tokens:
              ps.append(p)
          # Add punctuation
          elif (p in self.PUNCT_LIST) and self.punct:
              ps.append(p)
          # Warn about unknown char/phoneme
          elif p != space:
              message = f"Text: [{' '.join(g2p_text)}] contains unknown char/phoneme: [{p}]."
              if raw_text is not None:
                  message += f"Original text: [{raw_text}]. Symbol will be skipped."
              logging.warning(message)
  
      # Remove trailing spaces
      if ps:
          while ps[-1] == space:
              ps.pop()
  
      if self.pad_with_space:
          ps = [space] + ps + [space]
  
      return [self._token2id[p] for p in ps]
  
imports: import itertools
  import string
  from abc import ABC, abstractmethod
  from contextlib import contextmanager
  from typing import List, Optional
  from nemo.collections.common.tokenizers.text_to_speech.ipa_lexicon import get_grapheme_character_set, get_ipa_punctuation_list, validate_locale
  from nemo.collections.common.tokenizers.text_to_speech.tokenizer_utils import any_locale_text_preprocessing, chinese_text_preprocessing, english_text_preprocessing, french_text_preprocessing, italian_text_preprocessing, spanish_text_preprocessing
  from nemo.utils import logging
  from nemo.utils.decorators import experimental
label_desc: Use image node_id 3 for calling the ChinesePhonemesTokenizer obj's underlying member method code with example usage: obj.encode_from_g2p(g2p_text, raw_text) and returns: unknown