code: def transformer_latent_decoder(x,
                                 encoder_output,
                                 ed_attention_bias,
                                 hparams,
                                 name=None):
    
    with tf.variable_scope(name, default_name="transformer_latent_dec"):
      batch_size = common_layers.shape_list(x)[0]
      compressed_img_len = (hparams.img_len //
                            2**(hparams.num_compress_steps // 2))
      x = tf.reshape(x, [batch_size,
                         compressed_img_len,
                         compressed_img_len * hparams.num_latents,
                         hparams.hidden_size])
      decoder_input, _, _ = cia.prepare_decoder(x, hparams)
      decoder_output = cia.transformer_decoder_layers(
          decoder_input,
          encoder_output,
          hparams.num_latent_layers or hparams.num_hidden_layers,
          hparams,
          attention_type=hparams.latent_attention_type,
          encoder_decoder_attention_bias=ed_attention_bias,
          name="decoder")
      decoder_output = tf.reshape(decoder_output,
                                  [batch_size,
                                   compressed_img_len**2 * hparams.num_latents,
                                   hparams.hidden_size])
      return decoder_output
docs: Transformer decoder over latents using latent_attention_type.
  
    Args:
      x: Tensor of shape [batch, length_q, hparams.hidden_size]. length_q is the
        latent length, which is
        height * width * hparams.num_latents / (2**hparams.num_compress_steps).
      encoder_output: Tensor of shape [batch, length_kv, hparams.hidden_size].
      ed_attention_bias: Tensor which broadcasts with shape [batch,
        hparams.num_heads, length_q, length_kv]. Encoder-decoder attention bias.
      hparams: HParams.
      name: string, variable scope.
  
    Returns:
      Tensor of shape [batch, length_q, hparams.hidden_size].