import tensorflow as tf

    # noise = dist * self.epsilon_sphere_noise()
    # tf.stop_gradient(noise)
    noise = tf.random_normal(self.model.encode.get_shape().as_list()) * FLAGS.epsilon
    noisy_encoding = noise + self.models[1].encode
    tf.stop_gradient(noisy_encoding)  # or maybe here, who knows
    noisy_decode = interpreter.build_decoder(noisy_encoding, model.config, reuse=True, masks=model.mask_list)
    loss = interpreter.l2_loss(noisy_decode, self.raw_targets[1], alpha=FLAGS.beta)
    self.models += [noisy_decode]
    return loss

  def _tensor_to_image(self, net):
    with tf.name_scope('to_image'):
      if FLAGS.new_blur:
        net = net[..., :self.batch_shape[-1]]
      net = tf.nn.relu(net)
      net = tf.cast(net <= 1, net.dtype) * net * 255
      net = tf.cast(net, tf.uint8)
      return net

  def _image_to_tensor(self, image):
    with tf.name_scope('args_transform'):
      net = tf.cast(image, tf.float32) / 255.
      if FLAGS.new_blur:
        net = _blur_expand(net)
        FLAGS.blur = 0.
    return net

  def _init_optimizer(self):
    self.loss_total = tf.add_n(self.losses, 'loss_total')
    self.optimizer = self.optimizer_constructor(learning_rate=FLAGS.learning_rate)
