class_docstr: GPT-2 Language model.
class_docstr_tok: ["GPT-2","Language","model","."]
code: def forward(
      self,
      input_ids,
      position_ids,
      attention_mask,
      labels=None,
      tokentype_ids=None,
      inference_params=None,
  ):
      with self.forward_context():
          lm_output = self.language_model(
              input_ids,
              position_ids,
              attention_mask,
              inference_params=inference_params,
          )
  
          if self.post_process:
              return post_language_model_processing(
                  lm_output,
                  # note(mkozuki): Am I overlooking some order of dim change?
                  labels.t().contiguous(),
                  self.word_embeddings_weight(),
                  self.parallel_output,
                  self.fp16_lm_cross_entropy,
              )
          else:
              return lm_output
  
file_path: apex/apex/transformer/testing/standalone_gpt.py
imports: import contextlib
  import torch
  from apex.transformer.enums import AttnMaskType
  from apex.transformer.enums import ModelType
  from apex.transformer import tensor_parallel
  from apex.transformer.testing.global_vars import get_args
  from apex.transformer.testing.standalone_transformer_lm import MegatronModule
  from apex.transformer.testing.standalone_transformer_lm import parallel_lm_logits
  from apex.transformer.testing.standalone_transformer_lm import post_language_model_processing
  from apex.transformer.testing.standalone_transformer_lm import get_language_model
  from apex.transformer.testing.standalone_transformer_lm import init_method_normal
  from apex.transformer.testing.standalone_transformer_lm import scaled_init_method_normal
label_desc: Use image node_id 3 for calling the GPTModel obj's underlying member method code with example usage: obj.forward(input_ids, position_ids, attention_mask, labels, tokentype_ids, inference_params) and returns: post_language_model_processing, lm_output