class_docstr: A mixin class to support loading pre-trained checkpoints for modules
  that implement the XLNet model.
  
  The XLNet model was proposed in
  `XLNet: Generalized Autoregressive Pretraining for Language Understanding`_
  by `Yang et al.` It is based on the Transformer-XL model, pre-trained on a
  large corpus using a language modeling objective that considers all
  permutations of the input sentence.
  
  The available XLNet models are as follows:
  
    * ``xlnet-based-cased``: 12-layer, 768-hidden, 12-heads. This model is
      trained on full data (different from the one in the paper).
    * ``xlnet-large-cased``: 24-layer, 1024-hidden, 16-heads.
  
  We provide the following XLNet classes:
  
    * :class:`~texar.torch.modules.XLNetEncoder` for text encoding.
    * :class:`~texar.torch.modules.XLNetDecoder` for text generation and
      decoding.
    * :class:`~texar.torch.modules.XLNetClassifier` for text classification
      and sequence tagging.
    * :class:`~texar.torch.modules.XLNetRegressor` for text regression.
  
  .. _`XLNet: Generalized Autoregressive Pretraining for Language Understanding`:
      http://arxiv.org/abs/1906.08237
class_docstr_tok: ["A","mixin","class","to","support","loading","pre-trained","checkpoints","for","modules","that","implement","the","XLNet","model",".","The","XLNet","model","was","proposed","in","`","XLNet",":","Generalized","Autoregressive","Pretraining","for","Language","Understanding","`","_","by","`","Yang","et","al.","`","It","is","based","on","the","Transformer-XL","model",",","pre-trained","on","a","large","corpus","using","a","language","modeling","objective","that","considers","all","permutations","of","the","input","sentence",".","The","available","XLNet","models","are","as","follows",":","*","``","xlnet-based-cased","``",":","12-layer",",","768-hidden",",","12-heads",".","This","model","is","trained","on","full","data","(","different","from","the","one","in","the","paper",")",".","*","``","xlnet-large-cased","``",":","24-layer",",","1024-hidden",",","16-heads",".","We","provide","the","following","XLNet","classes",":","*",":","class",":","`","~texar.torch.modules.XLNetEncoder","`","for","text","encoding",".","*",":","class",":","`","~texar.torch.modules.XLNetDecoder","`","for","text","generation","and","decoding",".","*",":","class",":","`","~texar.torch.modules.XLNetClassifier","`","for","text","classification","and","sequence","tagging",".","*",":","class",":","`","~texar.torch.modules.XLNetRegressor","`","for","text","regression",".","..","_","`","XLNet",":","Generalized","Autoregressive","Pretraining","for","Language","Understanding","`",":","http",":","\/\/arxiv.org\/abs\/1906.08237"]
code: def _transform_config(cls, pretrained_model_name, cache_dir):
      info = list(os.walk(cache_dir))
      root, _, files = info[0]
      config_path = None
      for file in files:
          if file.endswith("config.json"):
              config_path = os.path.join(root, file)
      if config_path is None:
          raise ValueError(
              "Cannot find the config file in {}".format(cache_dir)
          )
  
      with open(config_path) as f:
          config_ckpt = json.loads(f.read())
  
      configs = {
          "head_dim": config_ckpt["d_head"],
          "ffn_inner_dim": config_ckpt["d_inner"],
          "hidden_dim": config_ckpt["d_model"],
          "activation": config_ckpt["ff_activation"],
          "num_heads": config_ckpt["n_head"],
          "num_layers": config_ckpt["n_layer"],
          "vocab_size": config_ckpt["n_token"],
          "untie_r": config_ckpt["untie_r"],
      }
  
      return configs
  
file_path: texar/texar/tf/modules/pretrained/xlnet.py
imports: import collections
  import json
  import os
  import re
  from abc import ABCMeta
  import tensorflow
  from texar.tf.modules.pretrained.pretrained_base import PretrainedMixin
label_desc: Use image node_id 1 for calling the PretrainedXLNetMixin obj's underlying member method code with example usage: obj._transform_config(cls, pretrained_model_name, cache_dir) and returns: configs