code: def test_hinge_loss():
      true_value = K.variable(np.array([[1.2], [1], [1], [1]]))
      pred_value = K.variable(np.array([[1.2], [0.1], [0], [-0.3]]))
      expected_loss = (0 + 1 - 0.3 + 0) / 2.0
      loss = K.eval(losses.RankHingeLoss()(true_value, pred_value))
      assert np.isclose(expected_loss, loss)
      expected_loss = (2 + 0.1 - 1.2 + 2 - 0.3 + 0) / 2.0
      loss = K.eval(
          losses.RankHingeLoss(margin=2)(true_value, pred_value)
      )
      assert np.isclose(expected_loss, loss)
      true_value = K.variable(
          np.array([[1.2], [1], [0.8], [1], [1], [0.8]])
      )
      pred_value = K.variable(
          np.array([[1.2], [0.1], [-0.5], [0], [0], [-0.3]])
      )
      expected_loss = (0 + 1 - 0.15) / 2.0
      loss = K.eval(
          losses.RankHingeLoss(num_neg=2, margin=1)(
              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 1 for calling a global function with example usage: test_hinge_loss() without return types