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
code: def __init__(
      self, pretrained_model_name=None, cache_dir=None, hparams=None
  ):
      super(BERTEncoder, self).__init__(hparams=hparams)
  
      self.load_pretrained_config(pretrained_model_name, cache_dir)
  
      with tf.variable_scope(self.variable_scope):
          # Word embedding
          self.word_embedder = WordEmbedder(
              vocab_size=self._hparams.vocab_size,
              hparams=self._hparams.embed,
          )
  
          # Segment embedding for each type of tokens
          self.segment_embedder = WordEmbedder(
              vocab_size=self._hparams.type_vocab_size,
              hparams=self._hparams.segment_embed,
          )
  
          # Position embedding
          self.position_embedder = PositionEmbedder(
              position_size=self._hparams.position_size,
              hparams=self._hparams.position_embed,
          )
  
          # The BERT encoder (a TransformerEncoder)
          self.encoder = TransformerEncoder(
              hparams=self._hparams.encoder
          )
  
          with tf.variable_scope("pooler"):
              kwargs_i = {
                  "units": self._hparams.hidden_size,
                  "activation": tf.tanh,
              }
              layer_hparams = {"type": "Dense", "kwargs": kwargs_i}
              self.pooler = get_layer(hparams=layer_hparams)
  
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 1 to create a new BERTEncoder object from inherited base classes: EncoderBase, PretrainedBERTMixin with example: obj = BERTEncoder(pretrained_model_name, cache_dir, hparams)