class_docstr: T5 decoder as a separate model.
  
  This module contains the decoder part of a pretrained T5. It is useful when
  adopting the pretrained T5 decoder as a part of a larger network. Note that
  the embedding layer should be created outside the module and provided as a
  parameter `shared_embedding` to share it in other parts of the network (e.g.,
  text encoder). If `shared_embedding` is not provided, the embedding layer is
  created within the module.
  
  Attributes:
    vocab_size: Size of the vocabulary.
    emb_dim: Size of the embeddings.
    num_heads: Number of attention heads.
    num_encoder_layers: Number of encoder layers.
    num_decoder_layers: Number of decoder layers.
    head_dim: Size of the embeddings in each head.
    mlp_dim: Size of the MLP output embeddings.
    dropout_rate: Dropout rate.
    dtype: Data type.
    mlp_activations: Sequence of activations in MLP.
    logits_via_embedding: Use the embedding weights for computing logits.
    shared_embedding: Optional. Embedding layer that is shared outside this
      module. If not given, a non-shared embedding layer will be created within
      the module.
docstr: Decode from the given encoded embedding using a T5 decoder.
  
  This method requires both decoder_target_tokens and decoder_input_tokens,
  which is a shifted version of the former. For a packed dataset, it usually
  has additional processing applied. For example, the first element of each
  sequence has id 0 instead of the shifted EOS id from the previous sequence.
  This function is a copy of the decode() method of t5.Transformer.
  
  Args:
    encoded: input embeddings obtained from an encoder.
    encoder_input_tokens: input data to the encoder.
    decoder_input_tokens: input token to the decoder.
    decoder_target_tokens: target token to the decoder.
    encoder_segment_ids: encoder segmentation info for packed examples.
    decoder_segment_ids: decoder segmentation info for packed examples.
    encoder_positions: encoder subsequence positions for packed examples.
    decoder_positions: decoder subsequence positions for packed examples.
    enable_dropout: Ensables dropout if set to True.
    decode: Whether to prepare and use an autoregressive cache.
    max_decode_length: Maximum length for autoregressive decoding.
  
  Returns:
    logits array from full transformer.
docstr_tok: ["Decode","from","the","given","encoded","embedding","using","a","T5","decoder",".","This","method","requires","both","decoder_target_tokens","and","decoder_input_tokens",",","which","is","a","shifted","version","of","the","former",".","For","a","packed","dataset",",","it","usually","has","additional","processing","applied",".","For","example",",","the","first","element","of","each","sequence","has","id","0","instead","of","the","shifted","EOS","id","from","the","previous","sequence",".","This","function","is","a","copy","of","the","decode","(",")","method","of","t5.Transformer",".","Args",":","encoded",":","input","embeddings","obtained","from","an","encoder",".","encoder_input_tokens",":","input","data","to","the","encoder",".","decoder_input_tokens",":","input","token","to","the","decoder",".","decoder_target_tokens",":","target","token","to","the","decoder",".","encoder_segment_ids",":","encoder","segmentation","info","for","packed","examples",".","decoder_segment_ids",":","decoder","segmentation","info","for","packed","examples",".","encoder_positions",":","encoder","subsequence","positions","for","packed","examples",".","decoder_positions",":","decoder","subsequence","positions","for","packed","examples",".","enable_dropout",":","Ensables","dropout","if","set","to","True",".","decode",":","Whether","to","prepare","and","use","an","autoregressive","cache",".","max_decode_length",":","Maximum","length","for","autoregressive","decoding",".","Returns",":","logits","array","from","full","transformer","."]
code: def __call__(
      self,
      encoded,
      encoder_input_tokens: jnp.ndarray,  # Only needed for masks.
      decoder_input_tokens: jnp.ndarray,
      decoder_target_tokens: jnp.ndarray,
      encoder_segment_ids: Optional[jnp.ndarray] = None,
      decoder_segment_ids: Optional[jnp.ndarray] = None,
      encoder_positions: Optional[jnp.ndarray] = None,
      decoder_positions: Optional[jnp.ndarray] = None,
      *,
      enable_dropout: bool = True,
      decode: bool = False,
      max_decode_length: Optional[int] = None,
  ):
      """Decode from the given encoded embedding using a T5 decoder.
  
      This method requires both decoder_target_tokens and decoder_input_tokens,
      which is a shifted version of the former. For a packed dataset, it usually
      has additional processing applied. For example, the first element of each
      sequence has id 0 instead of the shifted EOS id from the previous sequence.
      This function is a copy of the decode() method of t5.Transformer.
  
      Args:
        encoded: input embeddings obtained from an encoder.
        encoder_input_tokens: input data to the encoder.
        decoder_input_tokens: input token to the decoder.
        decoder_target_tokens: target token to the decoder.
        encoder_segment_ids: encoder segmentation info for packed examples.
        decoder_segment_ids: decoder segmentation info for packed examples.
        encoder_positions: encoder subsequence positions for packed examples.
        decoder_positions: decoder subsequence positions for packed examples.
        enable_dropout: Ensables dropout if set to True.
        decode: Whether to prepare and use an autoregressive cache.
        max_decode_length: Maximum length for autoregressive decoding.
  
      Returns:
        logits array from full transformer.
      """
  
      # Make padding attention masks.
      if decode:
          # Do not mask decoder attention based on targets padding at
          # decoding/inference time.
          decoder_mask = None
          encoder_decoder_mask = t5_layers.make_attention_mask(
              jnp.ones_like(decoder_target_tokens),
              encoder_input_tokens > 0,
              dtype=self.dtype,
          )
      else:
          decoder_mask = t5_layers.make_decoder_mask(
              decoder_target_tokens=decoder_target_tokens,
              dtype=self.dtype,
              decoder_segment_ids=decoder_segment_ids,
          )
          encoder_decoder_mask = t5_layers.make_attention_mask(
              decoder_target_tokens > 0,
              encoder_input_tokens > 0,
              dtype=self.dtype,
          )
  
      # Add segmentation block-diagonal attention masks if using segmented data.
      if encoder_segment_ids is not None:
          if decode:
              raise ValueError(
                  "During decoding, packing should not be used but "
                  "`encoder_segment_ids` was passed to `Transformer.decode`."
              )
  
          encoder_decoder_mask = t5_layers.combine_masks(
              encoder_decoder_mask,
              t5_layers.make_attention_mask(
                  decoder_segment_ids,
                  encoder_segment_ids,
                  jnp.equal,
                  dtype=self.dtype,
              ),
          )
  
      logits = self.decoder_module(
          encoded,
          decoder_input_tokens=decoder_input_tokens,
          decoder_positions=decoder_positions,
          decoder_mask=decoder_mask,
          encoder_decoder_mask=encoder_decoder_mask,
          deterministic=not enable_dropout,
          decode=decode,
          max_decode_length=max_decode_length,
      )
      return logits.astype(self.dtype)
  
imports: import functools
  from typing import Any, Dict, Mapping, Optional, Sequence, Tuple
  import flax.linen
  import jax
  import jax.numpy
  from scenic.model_lib.base_models import base_model
  from t5x import decoding
  from t5x.examples.t5 import layers
  from t5x.examples.t5 import network
  from t5x.models import DecodeFnCallable
label_desc: Use image node_id 2 for calling the T5Decoder obj's underlying member method code with example usage: obj.__call__(encoded, encoder_input_tokens, decoder_input_tokens, decoder_target_tokens, encoder_segment_ids, decoder_segment_ids, encoder_positions, decoder_positions) and returns: logits