code: def compress_encoder(
      inputs, hparams, strides=(2, 2), kernel_size=(3, 3), name=None
  ):
      """Encoder that compresses 2-D inputs by 2**num_compress_steps.
  
      Args:
        inputs: Tensor of shape [batch, height, width, channels].
        hparams: HParams.
        strides: Tuple, strides for conv block.
        kernel_size: Tuple, kernel window size for conv block.
        name: string, variable scope.
  
      Returns:
        Tensor of shape [batch, latent_length, hparams.hidden_size], where
          latent_length is
          hparams.num_latents * (height*width) / 2**(hparams.num_compress_steps).
      """
      with tf.variable_scope(name, default_name="compress"):
          x = inputs
          for i in range(hparams.num_compress_steps // 2):
              with tf.variable_scope("compress_conv_%d" % i):
                  y = common_layers.conv_block(
                      common_layers.layer_norm(
                          x, hparams.hidden_size, name="lnorm"
                      ),
                      hparams.hidden_size,
                      dilation_rates_and_kernel_sizes=[
                          ((1, 1), kernel_size)
                      ],
                      strides=strides,
                      padding="SAME",
                      name="compress_conv_%d" % i,
                  )
                  y = tf.nn.dropout(y, 1.0 - hparams.dropout)
                  if hparams.do_compress_attend:
                      y = compress_self_attention_layer(
                          x, hparams, name="compress_selfatt_%d" % i
                      )
                      y += x
                  x = y
  
          x = residual_block_layer(x, hparams)
  
          # If using multiple copies of latents, blow up the hidden size and then
          # reshape to increase by num_latents.
          shape_x = common_layers.shape_list(x)
          x = tf.layers.dense(
              x,
              hparams.num_latents * hparams.hidden_size,
              name=name + "_dense",
          )
          return tf.reshape(
              x,
              [
                  shape_x[0],
                  shape_x[1] * shape_x[2] * hparams.num_latents,
                  hparams.hidden_size,
              ],
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from six.moves import range
  from tensor2tensor.layers import common_attention
  from tensor2tensor.layers import common_image_attention
  from tensor2tensor.layers import common_layers
  from tensor2tensor.layers import transformer_layers
  from tensor2tensor.utils import beam_search
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
  import tensorflow_probability
label_desc: Use image node_id 7 for calling a global function with example usage: compress_encoder(inputs, hparams, strides, kernel_size, name) and returns: tf