code: def test_op_sequence_reduce_sum(device_id, precision):
      a = C.sequence.input_variable(
          shape=(1,),
          dtype=sanitize_dtype_cntk(PRECISION_TO_TYPE[precision]),
          needs_gradient=True,
          name="a",
      )
  
      sequence_sum_a_plus_sequence_sum_a = C.sequence.reduce_sum(
          a
      ) + C.sequence.reduce_sum(a)
  
      a_data = [
          AA([[2]], dtype=PRECISION_TO_TYPE[precision]),
          AA([[2], [3]], dtype=PRECISION_TO_TYPE[precision]),
          AA([[2], [3], [4]], dtype=PRECISION_TO_TYPE[precision]),
      ]
  
      actual_grad = sequence_sum_a_plus_sequence_sum_a.grad(
          {a: a_data}, [a]
      )
      assert np.array_equal(actual_grad[0], np.asarray([[2.0]]))
      assert np.array_equal(actual_grad[1], np.asarray([[2.0], [2.0]]))
      assert np.array_equal(
          actual_grad[2], np.asarray([[2.0], [2.0], [2.0]])
      )
  
      res = sequence_sum_a_plus_sequence_sum_a.eval({a: a_data})
      assert np.array_equal(res[0], np.asarray([4.0]))
      assert np.array_equal(res[1], np.asarray([10.0]))
      assert np.array_equal(res[2], np.asarray([18.0]))
  
      # Verify that calling sequence reduction on a placeholder with known
      # shape but unknown dynamic axes does not result in a problem
      p = C.placeholder(shape=(1,))
      r = C.sequence.reduce_sum(p)
      r.replace_placeholder(a)
  
      res = r.eval({a: a_data})
      assert np.array_equal(res[0], np.asarray([2.0]))
      assert np.array_equal(res[1], np.asarray([5.0]))
      assert np.array_equal(res[2], np.asarray([9.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 25 for calling a global function with example usage: test_op_sequence_reduce_sum(device_id, precision) without return types