import tensorflow as tf

      y_pow: int, to whcih the labels should be raised; useful if model diverge. e.g. y_pow=2
      num_ratings: numbers of rater to used, typically num_classes of the model
      batch_size: batch_size of the training or validation ops
      eps: a float, prevents divide by zero
      name: Optional scope/name for op_scope.

  Returns:
      A tensor with the kappa loss.
  """
  with tf.name_scope(name):
    labels = tf.to_float(labels)
    repeat_op = tf.to_float(
        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]))

