code: def _no_backprop_test(
      x, op, data, w, expected_x_backward, expected_w_backward
  ):
      # test direct input: no gradients pass through to inputs
      op_func = op(x)
      grad = op_func.grad({x: data}, [x])
      np.testing.assert_almost_equal(grad, expected_x_backward)
  
      # test inputs through sub-expressions: no gradients pass through to inputs (e.g. x, w) of the subexpressoin (e.g. x * w here)
      op_func = op(x * w)
      grad = op_func.grad({x: data}, [w, x])
      np.testing.assert_almost_equal(grad[x], expected_x_backward)
      np.testing.assert_almost_equal(grad[w], expected_w_backward)
  
      # testing inputs through shared sub-expressions: no gradients pass through reduce arg ops to inputs (e.g. x, w) of the subexpressoin
      # (e.g. x * w here), therefore the gradients will depend on how the shared expressions participate in other experssions:
      shared_exp = x * w
      op_func = op(shared_exp) + x + w + shared_exp
      ref_op_func = x + w + shared_exp
      grad = op_func.grad({x: data}, [w, x])
      ref_grad = ref_op_func.grad({x: data}, [w, x])
      np.testing.assert_almost_equal(grad[x], ref_grad[x])
      np.testing.assert_almost_equal(grad[w], ref_grad[w])
  
file_path: CNTK/bindings/python/cntk/ops/tests/stop_gradient_test.py
imports: import numpy
  import cntk
  from .ops_test_utils import AA, PRECISION_TO_TYPE, precision
  from cntk.internal import sanitize_dtype_cntk
  import pytest
  from .non_diff_test import Matrices
label_desc: Use image node_id 2 for calling a global function with example usage: _no_backprop_test(x, op, data, w, expected_x_backward, expected_w_backward) without return types