import tensorflow as tf

         Shape [batch_size, embeddings_dim]

  Return: pull away term loss
  """
  with tf.name_scope(name):
    norm = tf.sqrt(tf.reduce_sum(tf.square(embeddings), 1, keep_dims=True))
    normalized_embeddings = embeddings / norm
    similarity = tf.matmul(normalized_embeddings, normalized_embeddings, transpose_b=True)
    batch_size = tf.cast(tf.shape(embeddings)[0], tf.float32)
    pt_loss = (tf.reduce_sum(similarity) - batch_size) / \
        (batch_size * (batch_size - 1))
    return pt_loss


def log_sum_exp(x):
  """numerically stable log_sum_exp implementation that prevents overflow."""
