import tensorflow as tf

    return loss


def log_loss_tf(predictions, labels, eps=1e-7, weights=1.0, name='log_loss'):
  """Define a log loss.

  Args:
      predictions: 2D tensor or array, [batch_size, num_classes] predictions of the network .
      labels: 2D or array tensor, [batch_size, num_classes]  ground truth labels or target labels.
      eps: a constant to set upper or lower limit for labels, smoothening factor
      name: Optional scope/name for op_scope.

  Returns:
      A tensor with the log loss.
  """
  with tf.name_scope(name):
    predictions.get_shape().assert_is_compatible_with(labels.get_shape())
    predictions = tf.to_float(predictions)
    labels = tf.to_float(labels)
    losses = -tf.multiply(labels, tf.log(predictions + eps)) - tf.multiply(
        (1 - labels), tf.log(1 - predictions + eps))
  return tf.losses.compute_weighted_loss(losses, weights)


def kappa_loss(predictions, labels, y_pow=1, eps=1e-15, num_ratings=5, batch_size=32, name='kappa'):
  """Define a kappa loss, Its a continuous differentiable approximation of
  discrete kappa loss.

  Args:
      predictions: 2D tensor or array, [batch_size, num_classes] predictions of the network .
