class_docstr: Image-to-image transformer predicting blocks of the output in parallel.
class_docstr_tok: ["Image-to-image","transformer","predicting","blocks","of","the","output","in","parallel","."]
code: def top(self, body_output, features):
      assert self._hparams.block_size > 0
  
      train_or_eval = (
          self._hparams.mode == tf_estimator.ModeKeys.TRAIN
          or self._hparams.mode == tf_estimator.ModeKeys.EVAL
      )
  
      if train_or_eval:
          if self._hparams.mode == tf_estimator.ModeKeys.TRAIN:
              features["block_index"] = tf.random_uniform(
                  shape=[],
                  minval=0,
                  maxval=self._hparams.block_size,
                  dtype=tf.int64,
              )
          else:
              features["block_index"] = 0
          body_output = body_output[:, :, :, features["block_index"], :]
  
      decoded_image = tf.layers.dense(
          body_output,
          256,
          use_bias=True,
          activation=None,
          name="output_conv",
      )
  
      assert len(features["targets"].shape) == 4
      targets_shape = common_layers.shape_list(features["targets"])
  
      if train_or_eval:
          output = tf.reshape(decoded_image, targets_shape + [256])
      else:
          output = tf.reshape(
              decoded_image,
              [targets_shape[0], -1, self._hparams.block_size, 1, 256],
          )
          output = output[:, : targets_shape[1], :, :, :]
  
      return output
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import copy
  import numpy
  from tensor2tensor.layers import common_hparams
  from tensor2tensor.layers import common_image_attention
  from tensor2tensor.layers import common_layers
  from tensor2tensor.layers import modalities
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import t2t_model
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
label_desc: Use image node_id 2 for calling the Img2imgTransformerBlockParallel obj's underlying member method code with example usage: obj.top(body_output, features) and returns: output