import tensorflow as tf


    private_samples = tf.nn.l2_normalize(private_samples, 1)
    shared_samples = tf.nn.l2_normalize(shared_samples, 1)

    correlation_matrix = tf.matmul(private_samples, shared_samples, transpose_a=True)

    cost = tf.reduce_mean(tf.square(correlation_matrix)) * weight
    cost = tf.where(cost > 0, cost, 0, name='value')

  assert_op = tf.Assert(tf.is_finite(cost), [cost])
  with tf.control_dependencies([assert_op]):
    barrier = tf.no_op(name)
  return cost


def log_quaternion_loss_batch(predictions, labels, name='log_quaternion_batch_loss'):
  """A helper function to compute the error between quaternions.

