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: Returns a dictionary of hyperparameters with default values.
  
  * The tokenizer is determined by the constructor argument
    :attr:`pretrained_model_name` if it's specified. In this case,
    `hparams` are ignored.
  * Otherwise, the tokenizer is determined by
    `hparams['pretrained_model_name']` if it's specified. All other
    configurations in `hparams` are ignored.
  * If the above two are `None`, the tokenizer is defined by the
    configurations in `hparams`.
  
  .. code-block:: python
  
      {
          "pretrained_model_name": "117M",
          "vocab_file": None,
          "merges_file": None,
          "max_len": 1024,
          "bos_token": "<|endoftext|>",
          "eos_token": "<|endoftext|>",
          "unk_token": "<|endoftext|>",
          "pad_token": "<|endoftext|>",
          "errors": "replace",
      }
  
  Here:
  
  `"pretrained_model_name"`: str or None
      The name of the pre-trained GPT2 model.
  
  `"vocab_file"`: str or None
      The path to a vocabulary json file mapping tokens to ids.
  
  `"merges_file"`: str or None
      The path to a merges file.
  
  `"max_len"`: int
      The maximum sequence length that this model might ever be used with.
  
  `"bos_token"`: str
      Beginning of sentence token
  
  `"eos_token"`: str
      End of sentence token
  
  `"unk_token"`: str
      Unknown token
  
  `"pad_token"`: str
      Padding token
  
  `"errors"`: str
      Response when mapping tokens to text fails. The possible values are
      `ignore`, `replace`, and `strict`.
  
  `"name"`: str
      Name of the tokenizer.
docstr_tok: ["Returns","a","dictionary","of","hyperparameters","with","default","values",".","*","The","tokenizer","is","determined","by","the","constructor","argument",":","attr",":","`","pretrained_model_name","`","if","it","'s","specified",".","In","this","case",",","`","hparams","`","are","ignored",".","*","Otherwise",",","the","tokenizer","is","determined","by","`","hparams","[","'pretrained_model_name","'","]","`","if","it","'s","specified",".","All","other","configurations","in","`","hparams","`","are","ignored",".","*","If","the","above","two","are","`","None","`",",","the","tokenizer","is","defined","by","the","configurations","in","`","hparams","`",".","..","code-block",":",":","python","{","``","pretrained_model_name","''",":","``","117M","''",",","``","vocab_file","''",":","None",",","``","merges_file","''",":","None",",","``","max_len","''",":","1024",",","``","bos_token","''",":","``","<","|endoftext|",">","''",",","``","eos_token","''",":","``","<","|endoftext|",">","''",",","``","unk_token","''",":","``","<","|endoftext|",">","''",",","``","pad_token","''",":","``","<","|endoftext|",">","''",",","``","errors","''",":","``","replace","''",",","}","Here",":","`","``","pretrained_model_name","''","`",":","str","or","None","The","name","of","the","pre-trained","GPT2","model",".","`","``","vocab_file","''","`",":","str","or","None","The","path","to","a","vocabulary","json","file","mapping","tokens","to","ids",".","`","``","merges_file","''","`",":","str","or","None","The","path","to","a","merges","file",".","`","``","max_len","''","`",":","int","The","maximum","sequence","length","that","this","model","might","ever","be","used","with",".","`","``","bos_token","''","`",":","str","Beginning","of","sentence","token","`","``","eos_token","''","`",":","str","End","of","sentence","token","`","``","unk_token","''","`",":","str","Unknown","token","`","``","pad_token","''","`",":","str","Padding","token","`","``","errors","''","`",":","str","Response","when","mapping","tokens","to","text","fails",".","The","possible","values","are","`","ignore","`",",","`","replace","`",",","and","`","strict","`",".","`","``","name","''","`",":","str","Name","of","the","tokenizer","."]
code: def default_hparams() -> Dict[str, Any]:
      r"""Returns a dictionary of hyperparameters with default values.
  
      * The tokenizer is determined by the constructor argument
        :attr:`pretrained_model_name` if it's specified. In this case,
        `hparams` are ignored.
      * Otherwise, the tokenizer is determined by
        `hparams['pretrained_model_name']` if it's specified. All other
        configurations in `hparams` are ignored.
      * If the above two are `None`, the tokenizer is defined by the
        configurations in `hparams`.
  
      .. code-block:: python
  
          {
              "pretrained_model_name": "117M",
              "vocab_file": None,
              "merges_file": None,
              "max_len": 1024,
              "bos_token": "<|endoftext|>",
              "eos_token": "<|endoftext|>",
              "unk_token": "<|endoftext|>",
              "pad_token": "<|endoftext|>",
              "errors": "replace",
          }
  
      Here:
  
      `"pretrained_model_name"`: str or None
          The name of the pre-trained GPT2 model.
  
      `"vocab_file"`: str or None
          The path to a vocabulary json file mapping tokens to ids.
  
      `"merges_file"`: str or None
          The path to a merges file.
  
      `"max_len"`: int
          The maximum sequence length that this model might ever be used with.
  
      `"bos_token"`: str
          Beginning of sentence token
  
      `"eos_token"`: str
          End of sentence token
  
      `"unk_token"`: str
          Unknown token
  
      `"pad_token"`: str
          Padding token
  
      `"errors"`: str
          Response when mapping tokens to text fails. The possible values are
          `ignore`, `replace`, and `strict`.
  
      `"name"`: str
          Name of the tokenizer.
      """
      return {
          "pretrained_model_name": "117M",
          "vocab_file": None,
          "merges_file": None,
          "max_len": 1024,
          "bos_token": "<|endoftext|>",
          "eos_token": "<|endoftext|>",
          "unk_token": "<|endoftext|>",
          "pad_token": "<|endoftext|>",
          "errors": "replace",
          "name": "gpt2_tokenizer",
          "@no_typecheck": ["pretrained_model_name"],
      }
  
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 10 for calling the GPT2Tokenizer obj's underlying member method code with example usage: obj.default_hparams() and returns: dict