class_docstr: Pre-trained GPT2 Tokenizer.
  
  Args:
      pretrained_model_name (optional): a `str`, the name of
          pre-trained model (e.g., `117M`). Please refer to
          :class:`~texar.torch.modules.PretrainedGPT2Mixin` for
          all supported models.
          If None, the model name in :attr:`hparams` is used.
      cache_dir (optional): the path to a folder in which the
          pre-trained models will be cached. If `None` (default),
          a default directory (``texar_data`` folder under user's home
          directory) will be used.
      hparams (dict or HParams, optional): Hyperparameters. Missing
          hyperparameter will be set to default values. See
          :meth:`default_hparams` for the hyperparameter structure
          and default values.
class_docstr_tok: ["Pre-trained","GPT2","Tokenizer",".","Args",":","pretrained_model_name","(","optional",")",":","a","`","str","`",",","the","name","of","pre-trained","model","(","e.g.",",","`","117M","`",")",".","Please","refer","to",":","class",":","`","~texar.torch.modules.PretrainedGPT2Mixin","`","for","all","supported","models",".","If","None",",","the","model","name","in",":","attr",":","`","hparams","`","is","used",".","cache_dir","(","optional",")",":","the","path","to","a","folder","in","which","the","pre-trained","models","will","be","cached",".","If","`","None","`","(","default",")",",","a","default","directory","(","``","texar_data","``","folder","under","user","'s","home","directory",")","will","be","used",".","hparams","(","dict","or","HParams",",","optional",")",":","Hyperparameters",".","Missing","hyperparameter","will","be","set","to","default","values",".","See",":","meth",":","`","default_hparams","`","for","the","hyperparameter","structure","and","default","values","."]
docstr: Tokenize a string. 
docstr_tok: ["Tokenize","a","string","."]
code: def _map_text_to_token(self, text: str) -> List[str]:  # type: ignore
      r"""Tokenize a string."""
      bpe_tokens: List[str] = []
      for token in re.findall(self.pat, text):
          token = "".join(
              self.byte_encoder[b] for b in token.encode("utf-8")
          )
          bpe_tokens.extend(
              bpe_token for bpe_token in self._bpe(token).split(" ")
          )
      return bpe_tokens
  
imports: from typing import Any, Dict, List, Optional, Tuple
  import os
  import json
  import regex
  from texar.tf.modules.pretrained.gpt2 import PretrainedGPT2Mixin
  from texar.tf.data.tokenizers.tokenizer_base import TokenizerBase
  from texar.tf.data.tokenizers.gpt2_tokenizer_utils import bytes_to_unicode, get_pairs
label_desc: Use image node_id 2 for calling the GPT2Tokenizer obj's underlying member method code with example usage: obj._map_text_to_token(text) and returns: bpe_tokens