class_docstr: Universal Transformer: Depth-wise recurrent transformer model.
class_docstr_tok: ["Universal","Transformer",":","Depth-wise","recurrent","transformer","model","."]
docstr: Decode Universal Transformer outputs from encoder representation.
  
  It is similar to "transformer.decode", but it uses
  "universal_transformer_util.universal_transformer_decoder" instead of
  "transformer.transformer_decoder".
  
  Args:
    decoder_input: inputs to bottom of the model. [batch_size, decoder_length,
      hidden_dim]
    encoder_output: Encoder representation. [batch_size, input_length,
      hidden_dim]
    encoder_decoder_attention_bias: Bias and mask weights for encoder-decoder
      attention. [batch_size, input_length]
    decoder_self_attention_bias: Bias and mask weights for decoder
      self-attention. [batch_size, decoder_length]
    hparams: hyperparmeters for model.
    cache: Unimplemented.
    decode_loop_step: Unused.
    nonpadding: optional Tensor with shape [batch_size, decoder_length]
    losses: Unused.
    **kwargs: additional arguments to pass to decoder_function
  
  Returns:
     Tuple of:
       Final decoder representation. [batch_size, decoder_length,
          hidden_dim]
       encoder_extra_output: which is extra encoder output used in some
          variants of the model (e.g. in ACT, to pass the ponder-time to body)
docstr_tok: ["Decode","Universal","Transformer","outputs","from","encoder","representation",".","It","is","similar","to","``","transformer.decode","''",",","but","it","uses","''","universal_transformer_util.universal_transformer_decoder","''","instead","of","''","transformer.transformer_decoder","''",".","Args",":","decoder_input",":","inputs","to","bottom","of","the","model",".","[","batch_size",",","decoder_length",",","hidden_dim","]","encoder_output",":","Encoder","representation",".","[","batch_size",",","input_length",",","hidden_dim","]","encoder_decoder_attention_bias",":","Bias","and","mask","weights","for","encoder-decoder","attention",".","[","batch_size",",","input_length","]","decoder_self_attention_bias",":","Bias","and","mask","weights","for","decoder","self-attention",".","[","batch_size",",","decoder_length","]","hparams",":","hyperparmeters","for","model",".","cache",":","Unimplemented",".","decode_loop_step",":","Unused",".","nonpadding",":","optional","Tensor","with","shape","[","batch_size",",","decoder_length","]","losses",":","Unused",".","*","*","kwargs",":","additional","arguments","to","pass","to","decoder_function","Returns",":","Tuple","of",":","Final","decoder","representation",".","[","batch_size",",","decoder_length",",","hidden_dim","]","encoder_extra_output",":","which","is","extra","encoder","output","used","in","some","variants","of","the","model","(","e.g",".","in","ACT",",","to","pass","the","ponder-time","to","body",")"]
code: def decode(
      self,
      decoder_input,
      encoder_output,
      encoder_decoder_attention_bias,
      decoder_self_attention_bias,
      hparams,
      cache=None,
      decode_loop_step=None,
      nonpadding=None,
      losses=None,
      **kwargs,
  ):
      """Decode Universal Transformer outputs from encoder representation.
  
      It is similar to "transformer.decode", but it uses
      "universal_transformer_util.universal_transformer_decoder" instead of
      "transformer.transformer_decoder".
  
      Args:
        decoder_input: inputs to bottom of the model. [batch_size, decoder_length,
          hidden_dim]
        encoder_output: Encoder representation. [batch_size, input_length,
          hidden_dim]
        encoder_decoder_attention_bias: Bias and mask weights for encoder-decoder
          attention. [batch_size, input_length]
        decoder_self_attention_bias: Bias and mask weights for decoder
          self-attention. [batch_size, decoder_length]
        hparams: hyperparmeters for model.
        cache: Unimplemented.
        decode_loop_step: Unused.
        nonpadding: optional Tensor with shape [batch_size, decoder_length]
        losses: Unused.
        **kwargs: additional arguments to pass to decoder_function
  
      Returns:
         Tuple of:
           Final decoder representation. [batch_size, decoder_length,
              hidden_dim]
           encoder_extra_output: which is extra encoder output used in some
              variants of the model (e.g. in ACT, to pass the ponder-time to body)
  
      """
      del decode_loop_step
      del losses
      # TODO(dehghani): enable caching.
      del cache
  
      decoder_input = tf.nn.dropout(
          decoder_input, 1.0 - hparams.layer_prepostprocess_dropout
      )
  
      # No caching in Universal Transformers!
      (
          decoder_output,
          dec_extra_output,
      ) = universal_transformer_util.universal_transformer_decoder(
          decoder_input,
          encoder_output,
          decoder_self_attention_bias,
          encoder_decoder_attention_bias,
          hparams,
          nonpadding=nonpadding,
          save_weights_to=self.attention_weights,
      )
  
      # Expand since t2t expects 4d tensors.
      return tf.expand_dims(decoder_output, axis=2), dec_extra_output
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from tensor2tensor.layers import common_attention
  from tensor2tensor.layers import common_layers
  from tensor2tensor.models import transformer
  from tensor2tensor.models.research import universal_transformer_util
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import registry
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling the UniversalTransformer obj's underlying member method code with example usage: obj.decode(decoder_input, encoder_output, encoder_decoder_attention_bias, decoder__attention_bias, hparams, cache, decode_loop_step, nonpadding, losses) and returns: tf,  dec_extra_output