code: def test_op_gather_sparse(device_id):
      input_sparse_indices = [[1, 3, 5, 5], [2, 4], [0, 2]]
      vocab_size = 6
      input_data = Value.one_hot(input_sparse_indices, vocab_size)
  
      a = C.sequence.input_variable(
          shape=(vocab_size,), is_sparse=True, name="a"
      )
  
      a_last = C.sequence.last(a)
      a_last_dense = C.times(a_last, np.eye(vocab_size))
      res = a_last_dense.eval({a: input_data})
      assert np.array_equal(
          res,
          [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0]],
      )
  
      a_last_2 = C.sequence.slice(a, -2, 0)
      a_last_2_dense = C.times(a_last_2, np.eye(vocab_size))
      res = a_last_2_dense.eval({a: input_data})
      assert np.array_equal(
          res,
          [
              [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1]],
              [[0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0]],
              [[1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0]],
          ],
      )
  
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 22 for calling a global function with example usage: test_op_gather_sparse(device_id) without return types