Adds isotropic gaussian-noise to each latent.

  Args:
    latents: 4-D or 5-D tensor, shape=(NTHWC) or (NHWC).
    hparams: HParams.
  Returns:
    latents: latents with isotropic gaussian noise appended.

def noise_op(latents, hparams):
  """Adds isotropic gaussian-noise to each latent.

  Args:
    latents: 4-D or 5-D tensor, shape=(NTHWC) or (NHWC).
    hparams: HParams.
  Returns:
    latents: latents with isotropic gaussian noise appended.
  """
  if hparams.latent_noise == 0 or hparams.mode != tf.estimator.ModeKeys.TRAIN:
    return latents
  latent_shape = common_layers.shape_list(latents)
  return latents + tf.random_normal(latent_shape, stddev=hparams.latent_noise)