class_docstr: Transformer decoder consisting of *config.decoder_layers* layers. Each layer is a [`TrOCRDecoderLayer`]
  
  Args:
      config: TrOCRConfig
code: def __init__(self, config: TrOCRConfig):
      super().__init__(config)
      self.dropout = config.dropout
      self.layerdrop = config.decoder_layerdrop
      self.padding_idx = config.pad_token_id
      self.embed_scale = (
          math.sqrt(config.hidden_size)
          if config.scale_embedding
          else 1.0
      )
  
      self.embed_tokens = nn.Embedding(
          config.vocab_size, config.hidden_size, self.padding_idx
      )
  
      if config.use_learned_position_embeddings:
          self.embed_positions = TrOCRLearnedPositionalEmbedding(
              config.max_position_embeddings, config.hidden_size
          )
      else:
          self.embed_positions = TrOCRSinusoidalPositionalEmbedding(
              config.max_position_embeddings + self.padding_idx + 1,
              config.hidden_size,
              self.padding_idx,
          )
  
      if config.layernorm_embedding:
          self.layernorm_embedding = nn.LayerNorm(config.hidden_size)
      else:
          self.layernorm_embedding = None
  
      self.layers = nn.ModuleList(
          [
              TrOCRDecoderLayer(config)
              for _ in range(config.decoder_layers)
          ]
      )
  
      self.gradient_checkpointing = False
      # Initialize weights and apply final processing
      self.post_init()
  
imports: import copy
  import math
  import random
  from typing import Optional, Tuple
  import torch
  from torch import nn
  from torch.nn import CrossEntropyLoss
  from ...activations import ACT2FN
  from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentions
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_start_docstrings, logging, replace_return_docstrings
  from .configuration_trocr import TrOCRConfig
label_desc: Use image node_id 1 to create a new TrOCRDecoder object from inherited base classes: TrOCRPreTrainedModel with example: obj = TrOCRDecoder(config)