import tensorflow as tf

        tf.tile(tf.reshape(tf.range(0, num_ratings), [num_ratings, 1]), [1, num_ratings]))
    repeat_op_sq = tf.square((repeat_op - tf.transpose(repeat_op)))
    weights = repeat_op_sq / tf.to_float((num_ratings - 1)**2)

    pred_ = predictions**y_pow
    try:
      pred_norm = pred_ / \
          (eps + tf.reshape(tf.reduce_sum(pred_, 1), [-1, 1]))
    except Exception:
      pred_norm = pred_ / \
          (eps + tf.reshape(tf.reduce_sum(pred_, 1), [batch_size, 1]))

    hist_rater_a = tf.reduce_sum(pred_norm, 0)
    hist_rater_b = tf.reduce_sum(labels, 0)

    conf_mat = tf.matmul(tf.transpose(pred_norm), labels)

    nom = tf.reduce_sum(weights * conf_mat)
    denom = tf.reduce_sum(weights * tf.matmul(
        tf.reshape(hist_rater_a, [num_ratings, 1]), tf.reshape(hist_rater_b, [1, num_ratings])) /
