class_docstr: TransformerDecoder is a stack of N decoder layers.
  
  Args:
      decoder_layer: an instance of the TransformerDecoderLayer() class (required).
      num_layers: the number of sub-decoder-layers in the decoder (required).
      norm: the layer normalization component (optional).
  
  Examples::
      >>> decoder_layer = nn.TransformerDecoderLayer(d_model=512, nhead=8)
      >>> transformer_decoder = nn.TransformerDecoder(decoder_layer, num_layers=6)
      >>> memory = torch.rand(10, 32, 512)
      >>> tgt = torch.rand(20, 32, 512)
      >>> out = transformer_decoder(tgt, memory)
class_docstr_tok: ["TransformerDecoder","is","a","stack","of","N","decoder","layers",".","Args",":","decoder_layer",":","an","instance","of","the","TransformerDecoderLayer","(",")","class","(","required",")",".","num_layers",":","the","number","of","sub-decoder-layers","in","the","decoder","(","required",")",".","norm",":","the","layer","normalization","component","(","optional",")",".","Examples",":",":",">",">",">","decoder_layer","=","nn.TransformerDecoderLayer","(","d_model=512",",","nhead=8",")",">",">",">","transformer_decoder","=","nn.TransformerDecoder","(","decoder_layer",",","num_layers=6",")",">",">",">","memory","=","torch.rand","(","10",",","32",",","512",")",">",">",">","tgt","=","torch.rand","(","20",",","32",",","512",")",">",">",">","out","=","transformer_decoder","(","tgt",",","memory",")"]
code: def __init__(self, decoder_layer, num_layers, norm=None):
      super().__init__()
      torch._C._log_api_usage_once(
          f"torch.nn.modules.{self.__class__.__name__}"
      )
      self.layers = _get_clones(decoder_layer, num_layers)
      self.num_layers = num_layers
      self.norm = norm
  
imports: import copy
  from typing import Optional, Any, Union, Callable
  import torch
  import warnings
  from torch import Tensor
  from ..None import functional
  from .module import Module
  from .activation import MultiheadAttention
  from .container import ModuleList
  from ..init import xavier_uniform_
  from .dropout import Dropout
  from .linear import Linear
  from .normalization import LayerNorm
label_desc: Use image node_id 1 to create a new TransformerDecoder object from inherited base classes: Module with example: obj = TransformerDecoder(decoder_layer, num_layers, norm)