class_docstr: A mixin class to support loading pre-trained checkpoints for modules
  that implement the BERT model.
  
  The BERT model was proposed in (`Devlin et al`. 2018)
  `BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding`_
  . A bidirectional Transformer language model pre-trained on large text
  corpora. Available model names include:
  
    * ``bert-base-uncased``: 12-layer, 768-hidden, 12-heads,
      110M parameters.
    * ``bert-large-uncased``: 24-layer, 1024-hidden, 16-heads,
      340M parameters.
    * ``bert-base-cased``: 12-layer, 768-hidden, 12-heads , 110M parameters.
    * ``bert-large-cased``: 24-layer, 1024-hidden, 16-heads,
      340M parameters.
    * ``bert-base-multilingual-uncased``: 102 languages, 12-layer,
      768-hidden, 12-heads, 110M parameters.
    * ``bert-base-multilingual-cased``: 104 languages, 12-layer, 768-hidden,
      12-heads, 110M parameters.
    * ``bert-base-chinese``: Chinese Simplified and Traditional, 12-layer,
      768-hidden, 12-heads, 110M parameters.
  
  We provide the following BERT classes:
  
    * :class:`~texar.tf.modules.BERTEncoder` for text encoding.
    * :class:`~texar.tf.modules.BERTClassifier` for text classification and
      sequence tagging.
  
  .. _`BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding`:
      https://arxiv.org/abs/1810.04805
class_docstr_tok: ["A","mixin","class","to","support","loading","pre-trained","checkpoints","for","modules","that","implement","the","BERT","model",".","The","BERT","model","was","proposed","in","(","`","Devlin","et","al","`",".","2018",")","`","BERT",":","Pre-training","of","Deep","Bidirectional","Transformers","for","Language","Understanding","`","_",".","A","bidirectional","Transformer","language","model","pre-trained","on","large","text","corpora",".","Available","model","names","include",":","*","``","bert-base-uncased","``",":","12-layer",",","768-hidden",",","12-heads",",","110M","parameters",".","*","``","bert-large-uncased","``",":","24-layer",",","1024-hidden",",","16-heads",",","340M","parameters",".","*","``","bert-base-cased","``",":","12-layer",",","768-hidden",",","12-heads",",","110M","parameters",".","*","``","bert-large-cased","``",":","24-layer",",","1024-hidden",",","16-heads",",","340M","parameters",".","*","``","bert-base-multilingual-uncased","``",":","102","languages",",","12-layer",",","768-hidden",",","12-heads",",","110M","parameters",".","*","``","bert-base-multilingual-cased","``",":","104","languages",",","12-layer",",","768-hidden",",","12-heads",",","110M","parameters",".","*","``","bert-base-chinese","``",":","Chinese","Simplified","and","Traditional",",","12-layer",",","768-hidden",",","12-heads",",","110M","parameters",".","We","provide","the","following","BERT","classes",":","*",":","class",":","`","~texar.tf.modules.BERTEncoder","`","for","text","encoding",".","*",":","class",":","`","~texar.tf.modules.BERTClassifier","`","for","text","classification","and","sequence","tagging",".","..","_","`","BERT",":","Pre-training","of","Deep","Bidirectional","Transformers","for","Language","Understanding","`",":","https",":","\/\/arxiv.org\/abs\/1810.04805"]
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)
              with open(config_path) as f:
                  config_ckpt = json.loads(f.read())
  
      if config_path is None:
          raise ValueError(
              "Cannot find the config file in {}".format(cache_dir)
          )
  
      configs = {}
      hidden_dim = config_ckpt["hidden_size"]
      configs["hidden_size"] = config_ckpt["hidden_size"]
      configs["embed"] = {"name": "word_embeddings", "dim": hidden_dim}
      configs["vocab_size"] = config_ckpt["vocab_size"]
  
      configs["segment_embed"] = {
          "name": "token_type_embeddings",
          "dim": hidden_dim,
      }
      configs["type_vocab_size"] = config_ckpt["type_vocab_size"]
  
      configs["position_embed"] = {
          "name": "position_embeddings",
          "dim": hidden_dim,
      }
      configs["position_size"] = config_ckpt["max_position_embeddings"]
  
      configs["encoder"] = {
          "name": "encoder",
          "embedding_dropout": config_ckpt["hidden_dropout_prob"],
          "num_blocks": config_ckpt["num_hidden_layers"],
          "multihead_attention": {
              "use_bias": True,
              "num_units": hidden_dim,
              "num_heads": config_ckpt["num_attention_heads"],
              "output_dim": hidden_dim,
              "dropout_rate": config_ckpt[
                  "attention_probs_dropout_prob"
              ],
              "name": "self",
          },
          "residual_dropout": config_ckpt["hidden_dropout_prob"],
          "dim": hidden_dim,
          "use_bert_config": True,
          "poswise_feedforward": {
              "layers": [
                  {
                      "type": "Dense",
                      "kwargs": {
                          "name": "intermediate",
                          "units": config_ckpt["intermediate_size"],
                          "activation": config_ckpt["hidden_act"],
                          "use_bias": True,
                      },
                  },
                  {
                      "type": "Dense",
                      "kwargs": {
                          "name": "output",
                          "units": hidden_dim,
                          "activation": None,
                          "use_bias": True,
                      },
                  },
              ],
          },
      }
      return configs
  
file_path: texar/texar/tf/modules/pretrained/bert.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 PretrainedBERTMixin obj's underlying member method code with example usage: obj._transform_config(cls, pretrained_model_name, cache_dir) and returns: configs