class_docstr: Transformer Model Decoder for sequence to sequence translation.
  
  Attributes:
    config: hyperparameters of the module
class_docstr_tok: ["Transformer","Model","Decoder","for","sequence","to","sequence","translation",".","Attributes",":","config",":","hyperparameters","of","the","module"]
docstr: Applies Transformer model on the inputs.
  
  Args:
    encoded: encoded input data from encoder.
    targets: target inputs.
    decoder_mask: decoder self-attention mask.
    encoder_decoder_mask: encoder-decoder attention mask.
    decode: whether to run in single-position autoregressive mode.
    train: whether to apply dropout
  
  Returns:
    output of a transformer decoder.
docstr_tok: ["Applies","Transformer","model","on","the","inputs",".","Args",":","encoded",":","encoded","input","data","from","encoder",".","targets",":","target","inputs",".","decoder_mask",":","decoder","self-attention","mask",".","encoder_decoder_mask",":","encoder-decoder","attention","mask",".","decode",":","whether","to","run","in","single-position","autoregressive","mode",".","train",":","whether","to","apply","dropout","Returns",":","output","of","a","transformer","decoder","."]
code: def __call__(
      self,
      encoded,
      targets,
      decoder_mask=None,
      encoder_decoder_mask=None,
      decode=False,
      train=False,
  ):
      """Applies Transformer model on the inputs.
  
      Args:
        encoded: encoded input data from encoder.
        targets: target inputs.
        decoder_mask: decoder self-attention mask.
        encoder_decoder_mask: encoder-decoder attention mask.
        decode: whether to run in single-position autoregressive mode.
        train: whether to apply dropout
  
      Returns:
        output of a transformer decoder.
      """
      cfg = self.config
  
      assert encoded.ndim == 3  # (batch, len, depth)
      assert targets.ndim == 2  # (batch, len)
  
      # Output tokens embedding table
      output_embed = nn.Embed(
          num_embeddings=cfg.vocab_size,
          features=cfg.emb_dim,
          embedding_init=nn.initializers.normal(stddev=1.0),
      )
  
      y = targets.astype("int32")
      if not decode:
          y = shift_right(y)
      y = output_embed(y)
      y = AddPositionEmbs(config=cfg, name="posembed_output")(
          y, decode=decode
      )
      y = nn.Dropout(rate=cfg.dropout_rate)(y, deterministic=not train)
  
      y = y.astype(cfg.dtype)
  
      # Target-Input Decoder
      for lyr in range(cfg.num_layers):
          y = EncoderDecoder1DBlock(
              config=cfg, name=f"encoderdecoderblock_{lyr}"
          )(
              y,
              encoded,
              decoder_mask=decoder_mask,
              encoder_decoder_mask=encoder_decoder_mask,
              decode=decode,
              train=train,
          )
      y = nn.LayerNorm(dtype=cfg.dtype, name="encoderdecoder_norm")(y)
  
      # Decoded Logits
      if cfg.get("logits_via_embedding", True):
          # Use the transpose of embedding matrix for logit transform.
          logits = output_embed.attend(y.astype(jnp.float32))
          # Correctly normalize pre-softmax logits for this shared case.
          logits = logits / jnp.sqrt(y.shape[-1])
      else:
          logits = nn.Dense(
              cfg.vocab_size,
              dtype=cfg.dtype,
              kernel_init=nn.initializers.xavier_uniform(),
              bias_init=nn.initializers.normal(stddev=1e-6),
              name="logitdense",
          )(y)
      return logits
  
imports: from typing import Any, Dict, Optional, Tuple
  from absl import logging
  from flax import linen
  from flax.training import common_utils
  from immutabledict import immutabledict
  import jax
  from jax import lax
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.model_lib.base_models import base_model
  from scenic.model_lib.base_models import model_utils
  from scenic.projects.mbt import model
  from scenic.projects.mbt.model import temporal_encode
label_desc: Use image node_id 1 for calling the Decoder obj's underlying member method code with example usage: obj.__call__(encoded, targets, decoder_mask, encoder_decoder_mask, decode, train) and returns: logits