import tensorflow as tf

      labels: 2D tensor or array,[batch_size, num_classes]  ground truth labels or target labels.
      label_smoothing: a float, used to smooth the labels for better generalization
                       if greater than 0 then smooth the labels.
      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
      log_scale: a float, used to multiply the clipped log loss, e.g: 0.5
      log_offset:a float minimum log loss offset to substract from original log loss; e.g. 0.50
      name: Optional scope/name for op_scope.

  Returns:
      A tensor with the kappa log loss.
  """
  with tf.name_scope(name):
    num_classes = labels.get_shape()[-1].value
    labels = tf.cast(labels, predictions.dtype)
    if label_smoothing > 0:
      smooth_positives = 1.0 - label_smoothing
      smooth_negatives = label_smoothing / num_classes
      labels = labels * smooth_positives + smooth_negatives
    log_loss_res = log_loss(predictions, labels)
    kappa_loss_res = kappa_loss(
        predictions, labels, y_pow=y_pow, num_ratings=num_classes, batch_size=batch_size)
    return kappa_loss_res + log_scale * (log_loss_res - log_offset)


