docstr: Tokenize the `g2p_text` that has been already run through G2P. Each item in the `g2p_text` would be encoded as
  one of the integer IDs predefined in `self._token2id`. Note that this function should be called after
  `self.text_preprocessing_func` and `self.g2p` functions
  
  Args:
      g2p_text (List[str]): a sequence of tokens from G2P's output. It could be a sequence of phonemes, a sequence
          of graphemes, or a mixture of both. For example, `['ˈ', 's', 'i', ' ', '#O', '#O', '#V']`, which is the
          G2P's output of the text "see OOV", where '#' is prepended to each grapheme in order to distinguish
          graphemes from phonemes if there are overlaps in between. The prefix '#' can be customized in
          `nemo.collections.tts.g2p.models.i18n_ipa.IpaG2p.grapheme_prefix`.
      raw_text (str): the original text after calling `self.text_preprocessing_func`. It is optional. It is only
          used to deliver a warning message that some graphemes from the original text are skipped.
  
  Returns: a list of integer IDs that tokenize the `g2p_text`.
docstr_tok: ["Tokenize","the","`","g2p_text","`","that","has","been","already","run","through","G2P",".","Each","item","in","the","`","g2p_text","`","would","be","encoded","as","one","of","the","integer","IDs","predefined","in","`","self._token2id","`",".","Note","that","this","function","should","be","called","after","`","self.text_preprocessing_func","`","and","`","self.g2p","`","functions","Args",":","g2p_text","(","List","[","str","]",")",":","a","sequence","of","tokens","from","G2P","'s","output",".","It","could","be","a","sequence","of","phonemes",",","a","sequence","of","graphemes",",","or","a","mixture","of","both",".","For","example",",","`","[","'","\u02c8","'",",","'s","'",",","'","i","'",",","'","'",",","'","#","O","'",",","'","#","O","'",",","'","#","V","'","]","`",",","which","is","the","G2P","'s","output","of","the","text","``","see","OOV","''",",","where","'","#","'","is","prepended","to","each","grapheme","in","order","to","distinguish","graphemes","from","phonemes","if","there","are","overlaps","in","between",".","The","prefix","'","#","'","can","be","customized","in","`","nemo.collections.tts.g2p.models.i18n_ipa.IpaG2p.grapheme_prefix","`",".","raw_text","(","str",")",":","the","original","text","after","calling","`","self.text_preprocessing_func","`",".","It","is","optional",".","It","is","only","used","to","deliver","a","warning","message","that","some","graphemes","from","the","original","text","are","skipped",".","Returns",":","a","list","of","integer","IDs","that","tokenize","the","`","g2p_text","`","."]
code: def encode_from_g2p(
      self, g2p_text: List[str], raw_text: Optional[str] = None
  ) -> List[int]:
      """
      Tokenize the `g2p_text` that has been already run through G2P. Each item in the `g2p_text` would be encoded as
      one of the integer IDs predefined in `self._token2id`. Note that this function should be called after
      `self.text_preprocessing_func` and `self.g2p` functions
  
      Args:
          g2p_text (List[str]): a sequence of tokens from G2P's output. It could be a sequence of phonemes, a sequence
              of graphemes, or a mixture of both. For example, `['ˈ', 's', 'i', ' ', '#O', '#O', '#V']`, which is the
              G2P's output of the text "see OOV", where '#' is prepended to each grapheme in order to distinguish
              graphemes from phonemes if there are overlaps in between. The prefix '#' can be customized in
              `nemo.collections.tts.g2p.models.i18n_ipa.IpaG2p.grapheme_prefix`.
          raw_text (str): the original text after calling `self.text_preprocessing_func`. It is optional. It is only
              used to deliver a warning message that some graphemes from the original text are skipped.
  
      Returns: a list of integer IDs that tokenize the `g2p_text`.
      """
      ps, space, tokens = [], self.tokens[self.space], set(self.tokens)
      for p in g2p_text:
          if p == space and len(ps) > 0 and ps[-1] != space:
              # Add space if last token isn't one
              ps.append(p)
          elif p in tokens:
              # Add next phoneme or char (if chars=True)
              ps.append(p)
          elif (p in self.punct_list) and self.punct:
              # Add punct
              ps.append(p)
          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]
  
      # Token index lookups
      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 IPATokenizer obj's underlying member method code with example usage: obj.encode_from_g2p(g2p_text, raw_text) and returns: unknown