class_docstr: Bert Language model.
class_docstr_tok: ["Bert","Language","model","."]
code: def __init__(
      self,
      config,
      num_tokentypes=2,
      add_binary_head=True,
      parallel_output=True,
      pre_process=True,
      post_process=True,
  ):
      super().__init__(config=config)
      args = get_args()
  
      # TODO this option is not yet implemented in BERT
      assert args.untie_embeddings_and_output_weights is False
  
      self.fp16_lm_cross_entropy = args.fp16_lm_cross_entropy
      self.add_binary_head = add_binary_head
      self.parallel_output = parallel_output
      self.pre_process = pre_process
      self.post_process = post_process
  
      self.return_embeddings = args.output_bert_embeddings
      if self.return_embeddings:
          assert self.post_process and self.add_binary_head
  
      (
          self.language_model,
          self._language_model_key,
      ) = get_language_model(
          config=config,
          num_tokentypes=num_tokentypes,
          add_pooler=self.add_binary_head,
          encoder_attn_mask_type=AttnMaskType.padding,
          pre_process=self.pre_process,
          post_process=self.post_process,
      )
  
      self.initialize_word_embeddings()
      if self.post_process:
          self.lm_head = BertLMHead(
              self.shared_embedding_or_output_weight().size(0),
              config,
              parallel_output,
          )
          self._lm_head_key = "lm_head"
          self.binary_head = None
          if self.add_binary_head:
              self.binary_head = get_linear_layer(
                  config.hidden_size, 2, config.init_method
              )
              self._binary_head_key = "binary_head"
  
imports: import torch
  from megatron import get_args
  from megatron.core import tensor_parallel
  from megatron.model.enums import AttnMaskType
  from megatron.model.language_model import parallel_lm_logits
  from megatron.model.language_model import get_language_model
  from megatron.model.utils import get_norm
  from megatron.model.utils import openai_gelu, erf_gelu
  from megatron.model.utils import get_linear_layer
  from megatron.model.utils import init_method_normal
  from megatron.model.utils import scaled_init_method_normal
  from .module import MegatronModule
label_desc: Use image node_id 1 to create a new BertModel object from inherited base classes: MegatronModule with example: obj = BertModel(config, num_tokentypes, add_binary_head, parallel_output, pre_process, post_process)