Soft Nearest Neighbor Loss
    :param x: a matrix.
    :param y: a list of labels for each element of x.
    :param temp: Temperature.
    :cos_distance: Boolean for using cosine or Euclidean distance.

    :returns: A tensor for the Soft Nearest Neighbor Loss of the points
              in x with labels y.

def SNNL(x, y, temp, cos_distance):
    """Soft Nearest Neighbor Loss
    :param x: a matrix.
    :param y: a list of labels for each element of x.
    :param temp: Temperature.
    :cos_distance: Boolean for using cosine or Euclidean distance.

    :returns: A tensor for the Soft Nearest Neighbor Loss of the points
              in x with labels y.
    """
    summed_masked_pick_prob = tf.reduce_sum(
        SNNLCrossEntropy.masked_pick_probability(x, y, temp, cos_distance), 1)
    return tf.reduce_mean(
        -tf.log(SNNLCrossEntropy.STABILITY_EPS + summed_masked_pick_prob))