docstr: See base class.
docstr_tok: ["See","base","class","."]
code: def encode(self, text):
      """See base class."""
      cs, space, tokens = [], self.tokens[self.space], set(self.tokens)
  
      text = self.text_preprocessing_func(text)
      for c in text:
          # Add a whitespace if the current char is a whitespace while the previous char is not a whitespace.
          if c == space and len(cs) > 0 and cs[-1] != space:
              cs.append(c)
          # Add the current char that is an alphanumeric or an apostrophe.
          elif (c.isalnum() or c == "'") and c in tokens:
              cs.append(c)
          # Add a punctuation that has a single char.
          elif (c in self.PUNCT_LIST) and self.punct:
              cs.append(c)
          # Warn about unknown char
          elif c != space:
              logging.warning(
                  f"Text: [{text}] contains unknown char: [{c}]. Symbol will be skipped."
              )
  
      # Remove trailing spaces
      if cs:
          while cs[-1] == space:
              cs.pop()
  
      if self.pad_with_space:
          cs = [space] + cs + [space]
  
      return [self._token2id[p] for p in cs]
  
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 2 for calling the BaseCharsTokenizer obj's underlying member method code with example usage: obj.encode(text) and returns: unknown