class_docstr: Rank cross entropy loss.
  
  Examples:
      >>> from keras import backend as K
      >>> softmax = lambda x: np.exp(x)/np.sum(np.exp(x), axis=0)
      >>> x_pred = K.variable(np.array([[1.0], [1.2], [0.8]]))
      >>> x_true = K.variable(np.array([[1], [0], [0]]))
      >>> expect = -np.log(softmax(np.array([[1.0], [1.2], [0.8]])))
      >>> loss = K.eval(RankCrossEntropyLoss(num_neg=2)(x_true, x_pred))
      >>> np.isclose(loss, expect[0]).all()
      True
docstr: Calculate rank cross entropy loss.
  
  :param y_true: Label.
  :param y_pred: Predicted result.
  :return: Crossentropy loss computed by user-defined negative number.
docstr_tok: ["Calculate","rank","cross","entropy","loss",".",":","param","y_true",":","Label",".",":","param","y_pred",":","Predicted","result",".",":","return",":","Crossentropy","loss","computed","by","user-defined","negative","number","."]
code: def call(
      self, y_true: np.array, y_pred: np.array, sample_weight=None
  ) -> np.array:
      """
      Calculate rank cross entropy loss.
  
      :param y_true: Label.
      :param y_pred: Predicted result.
      :return: Crossentropy loss computed by user-defined negative number.
      """
      logits = layers.Lambda(lambda a: a[:: (self._num_neg + 1), :])(
          y_pred
      )
      labels = layers.Lambda(lambda a: a[:: (self._num_neg + 1), :])(
          y_true
      )
      logits, labels = [logits], [labels]
      for neg_idx in range(self._num_neg):
          neg_logits = layers.Lambda(
              lambda a: a[neg_idx + 1 :: (self._num_neg + 1), :]
          )(y_pred)
          neg_labels = layers.Lambda(
              lambda a: a[neg_idx + 1 :: (self._num_neg + 1), :]
          )(y_true)
          logits.append(neg_logits)
          labels.append(neg_labels)
      logits = tf.concat(logits, axis=-1)
      labels = tf.concat(labels, axis=-1)
      smoothed_prob = tf.nn.softmax(logits) + np.finfo(float).eps
      loss = -(
          tf.reduce_sum(labels * tf.math.log(smoothed_prob), axis=-1)
      )
      return losses_utils.compute_weighted_loss(
          loss, sample_weight, reduction=self.reduction
      )
  
file_path: MatchZoo/matchzoo/losses/rank_cross_entropy_loss.py
imports: import numpy
  import tensorflow
  from keras import layers, backend
  from keras.losses import Loss
  from keras.utils import losses_utils
label_desc: Use image node_id 2 for calling the RankCrossEntropyLoss obj's underlying member method code with example usage: obj.call(y_true, y_pred, sample_weight) and returns: losses_utils