code: def __init__(
      self,
      units: int = 512,
      hidden_size: int = 2048,
      num_layers: int = 6,
      num_heads: int = 8,
      attention_dropout_prob: float = 0.0,
      hidden_dropout_prob: float = 0.0,
      output_attention: bool = False,
      output_all_encodings: bool = False,
      layer_norm_eps: float = 1e-12,
      activation="gelu",
      layout="NT",
  ):
      super().__init__()
      assert units % num_heads == 0, (
          "In BertTransformer, The units should be divided exactly "
          "by the number of heads. Received units={}, num_heads={}".format(
              units, num_heads
          )
      )
  
      self._num_layers = num_layers
      self._output_attention = output_attention
      self._output_all_encodings = output_all_encodings
      self._layout = layout
  
      self.all_layers = th.nn.ModuleList(
          [
              TransformerEncoderLayer(
                  units=units,
                  hidden_size=hidden_size,
                  num_heads=num_heads,
                  attention_dropout_prob=attention_dropout_prob,
                  hidden_dropout_prob=hidden_dropout_prob,
                  layer_norm_eps=layer_norm_eps,
                  activation=activation,
                  layout=layout,
              )
              for _ in range(num_layers)
          ]
      )
  
imports: import logging
  import torch
  from ..attention_cell import gen_self_attn_mask
  from .transformer import TransformerEncoderLayer
  from ..layers import get_activation, sequence_mask
  from ...utils.registry import Registry
  from ...models.bert import bert_cfg_reg
label_desc: Use image node_id 1 to create a new BertTransformer object from inherited base classes: th.nn with example: obj = BertTransformer(units, hidden_size, num_layers, num_heads, attention_dropout_prob, hidden_dropout_prob, output_attention, output_all_encodings, layer_norm_eps, activation, layout)