code: def test_op_gather_grad(device_id):
      dim = 10
      ii = C.sequence.input_variable(())
      param = C.parameter(
          (dim, 1),
          init=np.reshape(np.arange(dim), (dim, 1)).astype(np.float32),
      )
      ss = C.gather(param, ii)
      data = [[0], [0, 1, 2], [1, 2, 3, 4, 5, 6]]
      grad1 = ss.grad(data, wrt=[param])
      ss2 = C.times(
          C.one_hot(ii, num_classes=dim, sparse_output=False), param
      )
      grad2 = ss2.grad(data, wrt=[param])
      assert np.array_equal(grad1, grad2)
  
imports: from __future__ import division
  import numpy
  import pytest
  import cntk
  from .ops_test_utils import cntk_device
  from cntk.tests.test_utils import _to_dense, _to_csr
  from .ops_test_utils import unittest_helper, _test_unary_op, _test_binary_op, AA, precision, PRECISION_TO_TYPE, cntk_device
  from cntk import Value
  from cntk.axis import Axis
  from cntk.internal import sanitize_dtype_cntk
  from ..None import constant
label_desc: Use image node_id 23 for calling a global function with example usage: test_op_gather_grad(device_id) without return types