class_docstr: Reversible Residual Transformer.
  
  Layers are reversible and are recomputed on the backward pass.
  
  y1 = x1 + f(x2)
  y2 = x2 + g(y1)
  
  f: Attention
  g: Feed-forward
class_docstr_tok: ["Reversible","Residual","Transformer",".","Layers","are","reversible","and","are","recomputed","on","the","backward","pass",".","y1","=","x1","+","f","(","x2",")","y2","=","x2","+","g","(","y1",")","f",":","Attention","g",":","Feed-forward"]
code: def body(self, features):
      hparams = self._hparams
      targets = features["targets"]
      inputs = features["inputs"]
      target_space = features["target_space_id"]
  
      inputs = common_layers.flatten4d3d(inputs)
      targets = common_layers.flatten4d3d(targets)
  
      (
          encoder_input,
          encoder_self_attention_bias,
          encoder_decoder_attention_bias,
      ) = transformer.transformer_prepare_encoder(
          inputs, target_space, hparams
      )
      (
          decoder_input,
          decoder_self_attention_bias,
      ) = transformer.transformer_prepare_decoder(targets, hparams)
  
      encoder_input = tf.nn.dropout(
          encoder_input, 1.0 - hparams.layer_prepostprocess_dropout
      )
      decoder_input = tf.nn.dropout(
          decoder_input, 1.0 - hparams.layer_prepostprocess_dropout
      )
      encoder_output = transformer_revnet_encoder(
          encoder_input, encoder_self_attention_bias, hparams
      )
  
      decoder_output = transformer_revnet_decoder(
          decoder_input,
          encoder_output,
          decoder_self_attention_bias,
          encoder_decoder_attention_bias,
          hparams,
      )
      decoder_output = tf.expand_dims(decoder_output, 2)
  
      return decoder_output
  
file_path: tensor2tensor/tensor2tensor/models/research/transformer_revnet.py
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.utils import contrib
  from tensor2tensor.utils import registry
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
label_desc: Use image node_id 1 for calling the TransformerRevnet obj's underlying member method code with example usage: obj.body(features) and returns: decoder_output