import tensorflow as tf

    dist_loss1 = self._distance_loss(models[1].encode - models[0].encode)
    dist_loss2 = self._distance_loss(models[1].encode - models[2].encode)

    # Stitch it all together and train
    self.loss_reco = tf.add_n(reco_losses)
    self.loss_pred = pred_loss_0 + pred_loss_2
    self.loss_dist = dist_loss1 + dist_loss2
    self.losses = [self.loss_reco, self.loss_pred]

  def _distance_loss(self, distances):
    error = tf.nn.relu(l2(distances) - FLAGS.distance ** 2)
    return tf.reduce_sum(error)

  def _prediction_decode(self, prediction, target, model):
    """Predict encoding t3 by encoding (t2 and t1) and expect a good reconstruction"""
    predict_decode = interpreter.build_decoder(prediction, self.model.config, reuse=True, masks=model.mask_list)
    predict_loss = 1./2 * interpreter.l2_loss(predict_decode, target, alpha=FLAGS.alpha)
    self.models += [predict_decode]
    return predict_loss * FLAGS.gamma


  def build_denoising_model(self):
