code: def test_rank_crossentropy_loss():
      losses.neg_num = 1
  
      def softmax(x):
          return np.exp(x) / np.sum(np.exp(x), axis=0)
  
      true_value = K.variable(np.array([[1.0], [0.0], [0.0], [1.0]]))
      pred_value = K.variable(np.array([[0.8], [0.1], [0.8], [0.1]]))
      expected_loss = (
          -np.log(softmax([0.8, 0.1])[0])
          - np.log(softmax([0.8, 0.1])[1])
      ) / 2
      loss = K.eval(
          losses.RankCrossEntropyLoss()(true_value, pred_value)
      )
      assert np.isclose(expected_loss, loss)
      true_value = K.variable(
          np.array([[1.0], [0.0], [0.0], [0.0], [1.0], [0.0]])
      )
      pred_value = K.variable(
          np.array([[0.8], [0.1], [0.1], [0.8], [0.1], [0.1]])
      )
      expected_loss = (
          -np.log(softmax([0.8, 0.1, 0.1])[0])
          - np.log(softmax([0.8, 0.1, 0.1])[1])
      ) / 2
      loss = K.eval(
          losses.RankCrossEntropyLoss(num_neg=2)(true_value, pred_value)
      )
      assert np.isclose(expected_loss, loss)
  
imports: import numpy
  from keras import backend
  from matchzoo import losses
label_desc: Use image node_id 2 for calling a global function with example usage: test_rank_crossentropy_loss() and returns: unknown