class_docstr: Raw BERT Transformer for encoding sequences. Please see
  :class:`~texar.tf.modules.PretrainedBERTMixin` for a brief description
  of BERT.
  
  This module basically stacks
  :class:`~texar.tf.modules.WordEmbedder`,
  :class:`~texar.tf.modules.PositionEmbedder`,
  :class:`~texar.tf.modules.TransformerEncoder` and a dense pooler.
  
  Args:
      pretrained_model_name (optional): a `str`, the name
          of pre-trained model (e.g., ``bert-base-uncased``). Please refer to
          :class:`~texar.tf.modules.PretrainedBERTMixin` 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.
  
  .. document private functions
  .. automethod:: _build
docstr: Returns a dictionary of hyperparameters with default values.
  
  * The encoder arch is determined by the constructor argument
    :attr:`pretrained_model_name` if it's specified. In this case,
    `hparams` are ignored.
  * Otherwise, the encoder arch 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 encoder arch is defined by the
    configurations in `hparams` and weights are randomly initialized.
  
  .. code-block:: python
  
      {
          "pretrained_model_name": "bert-base-uncased",
          "embed": {
              "dim": 768,
              "name": "word_embeddings"
          },
          "vocab_size": 30522,
          "segment_embed": {
              "dim": 768,
              "name": "token_type_embeddings"
          },
          "type_vocab_size": 2,
          "position_embed": {
              "dim": 768,
              "name": "position_embeddings"
          },
          "position_size": 512,
  
          "encoder": {
              "dim": 768,
              "embedding_dropout": 0.1,
              "multihead_attention": {
                  "dropout_rate": 0.1,
                  "name": "self",
                  "num_heads": 12,
                  "num_units": 768,
                  "output_dim": 768,
                  "use_bias": True
              },
              "name": "encoder",
              "num_blocks": 12,
              "poswise_feedforward": {
                  "layers": [
                      {   "kwargs": {
                              "activation": "gelu",
                              "name": "intermediate",
                              "units": 3072,
                              "use_bias": True
                          },
                          "type": "Dense"
                      },
                      {   "kwargs": {"activation": None,
                          "name": "output",
                          "units": 768,
                          "use_bias": True
                          },
                          "type": "Dense"
                      }
                  ]
              },
              "residual_dropout": 0.1,
              "use_bert_config": True
          },
          "hidden_size": 768,
          "initializer": None,
          "name": "bert_encoder"
      }
  
  Here:
  
  The default parameters are values for uncased BERT-Base model.
  
  `"pretrained_model_name"`: str or None
      The name of the pre-trained BERT model. If None, the model
      will be randomly initialized.
  
  `"embed"`: dict
      Hyperparameters for word embedding layer.
  
  `"vocab_size"`: int
      The vocabulary size of `inputs` in BERT model.
  
  `"segment_embed"`: dict
      Hyperparameters for segment embedding layer.
  
  `"type_vocab_size"`: int
      The vocabulary size of the `segment_ids` passed into `BertModel`.
  
  `"position_embed"`: dict
      Hyperparameters for position embedding layer.
  
  `"position_size"`: int
      The maximum sequence length that this model might ever be used with.
  
  `"encoder"`: dict
      Hyperparameters for the TransformerEncoder.
      See :func:`~texar.tf.modules.TransformerEncoder.default_harams`
      for details.
  
  `"hidden_size"`: int
      Size of the pooler dense layer.
  
  `"initializer"`: dict, optional
      Hyperparameters of the default initializer that initializes
      variables created in this module.
      See :func:`~texar.tf.core.get_initializer` for details.
  
  `"name"`: str
      Name of the module.
docstr_tok: ["Returns","a","dictionary","of","hyperparameters","with","default","values",".","*","The","encoder","arch","is","determined","by","the","constructor","argument",":","attr",":","`","pretrained_model_name","`","if","it","'s","specified",".","In","this","case",",","`","hparams","`","are","ignored",".","*","Otherwise",",","the","encoder","arch","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","encoder","arch","is","defined","by","the","configurations","in","`","hparams","`","and","weights","are","randomly","initialized",".","..","code-block",":",":","python","{","``","pretrained_model_name","''",":","``","bert-base-uncased","''",",","``","embed","''",":","{","``","dim","''",":","768",",","``","name","''",":","``","word_embeddings","''","}",",","``","vocab_size","''",":","30522",",","``","segment_embed","''",":","{","``","dim","''",":","768",",","``","name","''",":","``","token_type_embeddings","''","}",",","``","type_vocab_size","''",":","2",",","``","position_embed","''",":","{","``","dim","''",":","768",",","``","name","''",":","``","position_embeddings","''","}",",","``","position_size","''",":","512",",","``","encoder","''",":","{","``","dim","''",":","768",",","``","embedding_dropout","''",":","0.1",",","``","multihead_attention","''",":","{","``","dropout_rate","''",":","0.1",",","``","name","''",":","``","self","''",",","``","num_heads","''",":","12",",","``","num_units","''",":","768",",","``","output_dim","''",":","768",",","``","use_bias","''",":","True","}",",","``","name","''",":","``","encoder","''",",","``","num_blocks","''",":","12",",","``","poswise_feedforward","''",":","{","``","layers","''",":","[","{","``","kwargs","''",":","{","``","activation","''",":","``","gelu","''",",","``","name","''",":","``","intermediate","''",",","``","units","''",":","3072",",","``","use_bias","''",":","True","}",",","``","type","''",":","``","Dense","''","}",",","{","``","kwargs","''",":","{","``","activation","''",":","None",",","``","name","''",":","``","output","''",",","``","units","''",":","768",",","``","use_bias","''",":","True","}",",","``","type","''",":","``","Dense","''","}","]","}",",","``","residual_dropout","''",":","0.1",",","``","use_bert_config","''",":","True","}",",","``","hidden_size","''",":","768",",","``","initializer","''",":","None",",","``","name","''",":","``","bert_encoder","''","}","Here",":","The","default","parameters","are","values","for","uncased","BERT-Base","model",".","`","``","pretrained_model_name","''","`",":","str","or","None","The","name","of","the","pre-trained","BERT","model",".","If","None",",","the","model","will","be","randomly","initialized",".","`","``","embed","''","`",":","dict","Hyperparameters","for","word","embedding","layer",".","`","``","vocab_size","''","`",":","int","The","vocabulary","size","of","`","inputs","`","in","BERT","model",".","`","``","segment_embed","''","`",":","dict","Hyperparameters","for","segment","embedding","layer",".","`","``","type_vocab_size","''","`",":","int","The","vocabulary","size","of","the","`","segment_ids","`","passed","into","`","BertModel","`",".","`","``","position_embed","''","`",":","dict","Hyperparameters","for","position","embedding","layer",".","`","``","position_size","''","`",":","int","The","maximum","sequence","length","that","this","model","might","ever","be","used","with",".","`","``","encoder","''","`",":","dict","Hyperparameters","for","the","TransformerEncoder",".","See",":","func",":","`","~texar.tf.modules.TransformerEncoder.default_harams","`","for","details",".","`","``","hidden_size","''","`",":","int","Size","of","the","pooler","dense","layer",".","`","``","initializer","''","`",":","dict",",","optional","Hyperparameters","of","the","default","initializer","that","initializes","variables","created","in","this","module",".","See",":","func",":","`","~texar.tf.core.get_initializer","`","for","details",".","`","``","name","''","`",":","str","Name","of","the","module","."]
code: def default_hparams():
      r"""Returns a dictionary of hyperparameters with default values.
  
      * The encoder arch is determined by the constructor argument
        :attr:`pretrained_model_name` if it's specified. In this case,
        `hparams` are ignored.
      * Otherwise, the encoder arch 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 encoder arch is defined by the
        configurations in `hparams` and weights are randomly initialized.
  
      .. code-block:: python
  
          {
              "pretrained_model_name": "bert-base-uncased",
              "embed": {
                  "dim": 768,
                  "name": "word_embeddings"
              },
              "vocab_size": 30522,
              "segment_embed": {
                  "dim": 768,
                  "name": "token_type_embeddings"
              },
              "type_vocab_size": 2,
              "position_embed": {
                  "dim": 768,
                  "name": "position_embeddings"
              },
              "position_size": 512,
  
              "encoder": {
                  "dim": 768,
                  "embedding_dropout": 0.1,
                  "multihead_attention": {
                      "dropout_rate": 0.1,
                      "name": "self",
                      "num_heads": 12,
                      "num_units": 768,
                      "output_dim": 768,
                      "use_bias": True
                  },
                  "name": "encoder",
                  "num_blocks": 12,
                  "poswise_feedforward": {
                      "layers": [
                          {   "kwargs": {
                                  "activation": "gelu",
                                  "name": "intermediate",
                                  "units": 3072,
                                  "use_bias": True
                              },
                              "type": "Dense"
                          },
                          {   "kwargs": {"activation": None,
                              "name": "output",
                              "units": 768,
                              "use_bias": True
                              },
                              "type": "Dense"
                          }
                      ]
                  },
                  "residual_dropout": 0.1,
                  "use_bert_config": True
              },
              "hidden_size": 768,
              "initializer": None,
              "name": "bert_encoder"
          }
  
      Here:
  
      The default parameters are values for uncased BERT-Base model.
  
      `"pretrained_model_name"`: str or None
          The name of the pre-trained BERT model. If None, the model
          will be randomly initialized.
  
      `"embed"`: dict
          Hyperparameters for word embedding layer.
  
      `"vocab_size"`: int
          The vocabulary size of `inputs` in BERT model.
  
      `"segment_embed"`: dict
          Hyperparameters for segment embedding layer.
  
      `"type_vocab_size"`: int
          The vocabulary size of the `segment_ids` passed into `BertModel`.
  
      `"position_embed"`: dict
          Hyperparameters for position embedding layer.
  
      `"position_size"`: int
          The maximum sequence length that this model might ever be used with.
  
      `"encoder"`: dict
          Hyperparameters for the TransformerEncoder.
          See :func:`~texar.tf.modules.TransformerEncoder.default_harams`
          for details.
  
      `"hidden_size"`: int
          Size of the pooler dense layer.
  
      `"initializer"`: dict, optional
          Hyperparameters of the default initializer that initializes
          variables created in this module.
          See :func:`~texar.tf.core.get_initializer` for details.
  
      `"name"`: str
          Name of the module.
      """
  
      return {
          "pretrained_model_name": "bert-base-uncased",
          "embed": {"dim": 768, "name": "word_embeddings"},
          "vocab_size": 30522,
          "segment_embed": {
              "dim": 768,
              "name": "token_type_embeddings",
          },
          "type_vocab_size": 2,
          "position_embed": {"dim": 768, "name": "position_embeddings"},
          "position_size": 512,
          "encoder": {
              "dim": 768,
              "embedding_dropout": 0.1,
              "multihead_attention": {
                  "dropout_rate": 0.1,
                  "name": "self",
                  "num_heads": 12,
                  "num_units": 768,
                  "output_dim": 768,
                  "use_bias": True,
              },
              "name": "encoder",
              "num_blocks": 12,
              "poswise_feedforward": {
                  "layers": [
                      {
                          "kwargs": {
                              "activation": "gelu",
                              "name": "intermediate",
                              "units": 3072,
                              "use_bias": True,
                          },
                          "type": "Dense",
                      },
                      {
                          "kwargs": {
                              "activation": None,
                              "name": "output",
                              "units": 768,
                              "use_bias": True,
                          },
                          "type": "Dense",
                      },
                  ]
              },
              "residual_dropout": 0.1,
              "use_bert_config": True,
          },
          "hidden_size": 768,
          "initializer": None,
          "name": "bert_encoder",
          "@no_typecheck": ["pretrained_model_name"],
      }
  
file_path: texar/texar/tf/modules/encoders/bert_encoder.py
imports: import tensorflow
  from texar.tf.core.layers import get_initializer, get_layer
  from texar.tf.modules.encoders.transformer_encoders import TransformerEncoder
  from texar.tf.modules.embedders.embedders import WordEmbedder
  from texar.tf.modules.embedders.position_embedders import PositionEmbedder
  from texar.tf.modules.encoders.encoder_base import EncoderBase
  from texar.tf.modules.pretrained.bert import PretrainedBERTMixin
label_desc: Use image node_id 3 for calling the BERTEncoder obj's underlying member method code with example usage: obj.default_hparams() and returns: dict