class_docstr: Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`OPTDecoderLayer`]
  
  Args:
      config: OPTConfig
class_docstr_tok: ["Transformer","decoder","consisting","of","*","config.num_hidden_layers","*","layers",".","Each","layer","is","a","[","`","OPTDecoderLayer","`","]","Args",":","config",":","OPTConfig"]
code: def __init__(self, config: OPTConfig):
      super().__init__(config)
      self.dropout = config.dropout
      self.layerdrop = config.layerdrop
      self.padding_idx = config.pad_token_id
      self.max_target_positions = config.max_position_embeddings
      self.vocab_size = config.vocab_size
  
      self.embed_tokens = nn.Embedding(
          config.vocab_size,
          config.word_embed_proj_dim,
          self.padding_idx,
      )
      self.embed_positions = OPTLearnedPositionalEmbedding(
          config.max_position_embeddings, config.hidden_size
      )
  
      if config.word_embed_proj_dim != config.hidden_size:
          self.project_out = nn.Linear(
              config.hidden_size, config.word_embed_proj_dim, bias=False
          )
      else:
          self.project_out = None
  
      if config.word_embed_proj_dim != config.hidden_size:
          self.project_in = nn.Linear(
              config.word_embed_proj_dim, config.hidden_size, bias=False
          )
      else:
          self.project_in = None
  
      # Note that the only purpose of `config._remove_final_layer_norm` is to keep backward compatibility
      # with checkpoints that have been fine-tuned before transformers v4.20.1
      # see https://github.com/facebookresearch/metaseq/pull/164
      if (
          config.do_layer_norm_before
          and not config._remove_final_layer_norm
      ):
          self.final_layer_norm = nn.LayerNorm(config.hidden_size)
      else:
          self.final_layer_norm = None
  
      self.layers = nn.ModuleList(
          [
              OPTDecoderLayer(config)
              for _ in range(config.num_hidden_layers)
          ]
      )
  
      self.gradient_checkpointing = False
      # Initialize weights and apply final processing
      self.post_init()
  
imports: import random
  from typing import List, Optional, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
  from transformers.activations import ACT2FN
  from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
  from transformers.modeling_utils import PreTrainedModel
  from transformers.utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from transformers.models.opt.configuration_opt import OPTConfig
label_desc: Use image node_id 1 to create a new OPTDecoder object from inherited base classes: OPTPreTrainedModel with example: obj = OPTDecoder(config)