code: def test_lambda_rank(grad, value, output, gain, device_id, precision):
      dt = PRECISION_TO_TYPE[precision]
  
      score = AA(output, dtype=dt).reshape(-1, 1, 1)
      gain = AA(gain, dtype=dt).reshape(-1, 1, 1)
      group = np.ones_like(score).reshape(-1, 1, 1)
  
      expected_value = AA(value, dtype=dt)
      expected_grad = AA(grad, dtype=dt)
  
      from cntk.losses import lambda_rank
  
      g = C.input_variable((1,))
      s = C.input_variable((1,), needs_gradient=True)
      n = C.input_variable((1,))
      f = lambda_rank(s, n, g)
  
      actual_grad, actual_value = f.grad(
          {s: score, n: gain, g: group}, [s], [f.output]
      )
  
      assert np.allclose(actual_value, expected_value)
      assert np.allclose(actual_grad, expected_grad)
  
file_path: CNTK/bindings/python/cntk/losses/tests/losses_test.py
imports: from __future__ import division
  import numpy
  import pytest
  import cntk
  from cntk.ops.tests.ops_test_utils import _test_binary_op, AA, precision, PRECISION_TO_TYPE, unittest_helper
label_desc: Use image node_id 4 for calling a global function with example usage: test_lambda_rank(grad, value, output, gain, device_id, precision) without return types