code: def __init__(self, config):
      super().__init__(config)
  
      self.embed_dim = config.hidden_size
  
      self.wte = nn.Embedding(config.vocab_size, self.embed_dim)
      self.wpe = nn.Embedding(
          config.max_position_embeddings, self.embed_dim
      )
  
      self.drop = nn.Dropout(config.embd_pdrop)
      self.h = nn.ModuleList(
          [GPT2Block(config) for _ in range(config.num_hidden_layers)]
      )
      self.ln_f = nn.LayerNorm(
          self.embed_dim, eps=config.layer_norm_epsilon
      )
  
      self.init_weights()
  
      # Model parallel
      self.model_parallel = False
      self.device_map = None
      self.gradient_checkpointing = False
  
imports: from dataclasses import dataclass
  from typing import Optional, Tuple
  from .configuration_gpt2 import GPT2Config
  from fastNLP.transformers.torch.activations import ACT2FN
  from fastNLP.transformers.torch.file_utils import ModelOutput, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, replace_return_docstrings
  from fastNLP.transformers.torch.modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentions, SequenceClassifierOutputWithPast, TokenClassifierOutput
  from fastNLP.transformers.torch.modeling_utils import Conv1D, PreTrainedModel, SequenceSummary, find_pruneable_heads_and_indices, prune_conv1d_layer
  from fastNLP.transformers.torch.utils.model_parallel_utils import assert_device_map, get_device_map
  from fastNLP.envs.imports import _NEED_IMPORT_TORCH
  from fastNLP.core.log import logger
label_desc: Use image node_id 1 to create a new GPT2Model object from inherited base classes: GPT2PreTrainedModel with example: obj = GPT2Model(config)