class_docstr: GPT-2 Language model.
class_docstr_tok: ["GPT-2","Language","model","."]
code: def __init__(
      self,
      num_tokentypes: int = 0,
      parallel_output: bool = True,
      pre_process: bool = True,
      post_process: bool = True,
      cpu_offload: bool = False,
  ):
      super().__init__()
      args = get_args()
  
      self.forward_context = contextlib.nullcontext
      if cpu_offload:
          self.forward_context = torch.autograd.graph.save_on_cpu
  
      self.parallel_output = parallel_output
      self.pre_process = pre_process
      self.post_process = post_process
      self.fp16_lm_cross_entropy = args.fp16_lm_cross_entropy
  
      (
          self.language_model,
          self._language_model_key,
      ) = get_language_model(
          num_tokentypes=num_tokentypes,
          add_pooler=False,
          encoder_attn_mask_type=AttnMaskType.causal,
          init_method=init_method_normal(args.init_method_std),
          scaled_init_method=scaled_init_method_normal(
              args.init_method_std, args.num_layers
          ),
          pre_process=self.pre_process,
          post_process=self.post_process,
      )
  
      self.initialize_word_embeddings(init_method_normal)
  
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 1 to create a new GPTModel object from inherited base classes: MegatronModule with example: obj = GPTModel(num_tokentypes, parallel_output, pre_process, post_process, cpu_offload)