import tensorflow as tf

        rand = tf.random_uniform(layer_shape[:-1] + [hparams.bottleneck_bits])
      else:
        rand = tf.random_uniform(layer_shape[:-3] + [
            1, 1, hparams.bottleneck_bits])
      d = 2.0 * tf.to_float(tf.less(0.5, rand)) - 1.0
      z = tf.layers.dense(d, final_filters, name="unbottleneck")
      return layer + z, 0.0

    # Embed.
    x = tf.layers.dense(
        features["cur_target_frame"], filters, name="latent_embed",
        bias_initializer=tf.random_normal_initializer(stddev=0.01))
    x = common_attention.add_timing_signal_nd(x)

    if hparams.full_latent_tower:
      for i in range(hparams.num_compress_steps):
        with tf.variable_scope("latent_downstride%d" % i):
          x = common_layers.make_even_size(x)
          if i < hparams.filter_double_steps:
            filters *= 2
          x = common_attention.add_timing_signal_nd(x)
          x = tf.layers.conv2d(x, filters, kernel,
