class_docstr: Transformer language model.
  
  Arguments:
      transformer_hparams: transformer hyperparameters
      vocab_size: vocabulary size
      max_sequence_length: maximum size of sequence. This
                           is used for positional embedding
      embedding_dropout_prob: dropout probability for embeddings
      num_tokentypes: size of the token-type embeddings. 0 value
                      will ignore this embedding
code: def forward(
      self,
      enc_input_ids,
      enc_position_ids,
      enc_attn_mask,
      dec_input_ids=None,
      dec_position_ids=None,
      dec_attn_mask=None,
      enc_dec_attn_mask=None,
      token_type_ids=None,
      layer_past=None,
      get_key_value=False,
      pooling_sequence_index=0,
      enc_hidden_states=None,
      output_enc_hidden_only=False,
      encoder_input=None,
      set_inference_key_value_memory=False,
      inference_max_sequence_len=None,
      checkpoint_activations_all_layers=None,
  ):
      # Embeddings.
      if self.pre_process and encoder_input is None:
          encoder_input = self.embedding(
              enc_input_ids,
              enc_position_ids,
              token_type_ids=token_type_ids,
          )
          if self.is_adapter_available():
              _sq, _bs, _hs = encoder_input.size()
              ptuning_adapter = self.get_adapter_module(
                  AdapterName.PTUNING_ADAPTER
              )
              v = ptuning_adapter.virtual_tokens
              if (
                  ptuning_adapter and _sq >= v
              ):  # The sequence should be longer the v to insert virtual embeddings.
                  virtual_embeddings = ptuning_adapter(_bs)
                  encoder_input = encoder_input[
                      v:, :, :
                  ]  # the first v tokens are pads so that they can be swapped out with virtual embeddings.
                  encoder_input = torch.concat(
                      [virtual_embeddings, encoder_input], dim=0
                  )
      else:
          pass
  
      # enc_attn_mask: [1, 1, s, s]
      if inference_max_sequence_len is not None:
          enc_seq_length = inference_max_sequence_len
      elif self.encoder.input_tensor is not None:
          if self.sequence_parallel:
              enc_seq_length = (
                  self.encoder.input_tensor.size(0)
                  * parallel_state.get_tensor_model_parallel_world_size()
              )
          else:
              enc_seq_length = self.encoder.input_tensor.size(0)
      else:
          if self.sequence_parallel:
              enc_seq_length = (
                  encoder_input.size(0)
                  * parallel_state.get_tensor_model_parallel_world_size()
              )
          else:
              enc_seq_length = encoder_input.size(0)
  
      if self.context_parallel:
          enc_seq_length = (
              enc_seq_length
              * parallel_state.get_context_parallel_world_size()
          )
  
      rotary_pos_emb = None
      encoder_self_attention_relative_position_bias = None
      if self.position_embedding_type == "rope":
          rotary_pos_emb = self.rotary_pos_emb(enc_seq_length)
  
          if self.context_parallel:
              rotary_pos_emb = self.get_position_embedding_on_this_context_parallel_rank(
                  rotary_pos_emb, 0
              )
      elif (
          self.position_embedding_type == "alibi"
          or self.position_embedding_type == "sandwich"
          or self.position_embedding_type == "kerple"
      ):
          encoder_self_attention_relative_position_bias = (
              self.encoder_relative_position_embedding(
                  query_seq_length=enc_seq_length,
                  key_seq_length=enc_seq_length,
              )
          )
          # causal attention bias: [1, head, 1, k]
          # non-causal attention bias: [1, head, q, k]
  
          if (
              self.context_parallel
              and encoder_self_attention_relative_position_bias.shape[
                  -2
              ]
              > 1
          ):
              encoder_self_attention_relative_position_bias = self.get_position_embedding_on_this_context_parallel_rank(
                  encoder_self_attention_relative_position_bias, 2
              )
  
      # encoder.
      if enc_hidden_states is None:
          encoder_output = self.encoder(
              encoder_input,
              enc_attn_mask,
              layer_past=layer_past,
              get_key_value=get_key_value,
              set_inference_key_value_memory=set_inference_key_value_memory,
              inference_max_sequence_len=inference_max_sequence_len,
              checkpoint_activations_all_layers=checkpoint_activations_all_layers,
              rotary_pos_emb=(rotary_pos_emb, None, None)
              if rotary_pos_emb is not None
              else None,  # This assumes that this being used as a GPT/BERT model only (no cross-attention)
              self_attention_relative_position_bias=encoder_self_attention_relative_position_bias,
          )
      else:
          encoder_output = enc_hidden_states.to(encoder_input.dtype)
  
      if self.post_process:
          if self.add_pooler:
              pooled_output = self.pooler(
                  encoder_output, pooling_sequence_index
              )
  
      # output_enc_hidden_only refers to when we just need the encoder's
      # output. For example, it is helpful to compute
      # similarity between two sequences by average pooling
      if not self.add_decoder or output_enc_hidden_only:
          if self.add_pooler and self.post_process:
              return encoder_output, pooled_output
          else:
              return encoder_output
  
      # Decoder Embedding
      dec_embedding_output = self.embedding(
          dec_input_ids, dec_position_ids
      )
      # decoder
      decoder_output = self.decoder(
          dec_embedding_output,
          dec_attn_mask,
          layer_past=layer_past,
          get_key_value=get_key_value,
          encoder_output=encoder_output,
          enc_dec_attn_mask=enc_dec_attn_mask,
          set_inference_key_value_memory=set_inference_key_value_memory,
          inference_max_sequence_len=inference_max_sequence_len,
          checkpoint_activations_all_layers=checkpoint_activations_all_layers,
      )
  
      if self.add_pooler and self.post_process:
          return decoder_output, encoder_output, pooled_output
      else:
          return decoder_output, encoder_output
  
imports: from ast import Mod
  import torch
  from nemo.collections.nlp.modules.common.megatron.adapters.parallel_adapters import AdapterName, PromptEncoderAdapterConfig
  from nemo.collections.nlp.modules.common.megatron.layer_type import LayerType
  from nemo.collections.nlp.modules.common.megatron.module import MegatronModule
  from nemo.collections.nlp.modules.common.megatron.position_embedding import ALiBiRelativePositionEmbedding, KERPLERelativePositionEmbedding, RotaryEmbedding, SandwichRelativePositionEmbedding
  from nemo.collections.nlp.modules.common.megatron.transformer import ParallelTransformer
  from nemo.collections.nlp.modules.common.megatron.utils import ApexGuardDefaults, get_linear_layer, init_method_normal, scaled_init_method_normal
  from nemo.collections.nlp.parts import utils_funcs
  from nemo.core import adapter_mixins
label_desc: Use image node_id 4 for calling the TransformerLanguageModel obj's underlying member method code with example usage: obj.forward(enc_input_ids, enc_position_ids, enc_attn_mask, dec_input_ids, dec_position_ids, dec_attn_mask, enc_dec_attn_mask, token_type_ids, layer_past, get_key_value, pooling_sequence_index, enc_hidden_states, output_enc_hidden_only, encoder_input, set_inference_key_value_memory, inference_max_sequence_len, checkpoint_activations_all_layers) and returns: decoder_output,  encoder_output,  pooled_output, decoder_output,  encoder_output, encoder_output,  pooled_output, encoder_output