code: def test_op_reshape_subshape(
      input_shape,
      replacement_shape,
      begin_axis,
      end_axis,
      expected_output_shape,
      device_id,
      precision,
  ):
      # Reshaping is just moving the input values to different indexes of the result tensor.
      # If we compute the gradients on the unmodified tensor, reshape would get 1 for all inputs
      # For testing the gradients we want to have different gradients for each input index otherwise we can't
      # test if they get wrongly permuted during test. To this end we multiply
      # the reshaping result with itself.
      dev = cntk_device(device_id)
      from cntk.internal import sanitize_dtype_cntk
      from .. import reshape, element_times
  
      num_tensor_elements = np.multiply.reduce(input_shape)
      input_tensor = np.arange(
          num_tensor_elements, dtype=PRECISION_TO_TYPE[precision]
      ).reshape(input_shape)
      input_reshaped = input_tensor.reshape(expected_output_shape)
  
      a = C.input_variable(
          shape=input_tensor.shape,
          dtype=sanitize_dtype_cntk(PRECISION_TO_TYPE[precision]),
          needs_gradient=True,
          name="a",
      )
  
      a_reshaped = reshape(a, replacement_shape, begin_axis, end_axis)
  
      const_input_reshaped = constant(input_reshaped, device=dev)
      input_op = element_times(a_reshaped, const_input_reshaped)
  
      expected_forward = [input_reshaped**2]
      expected_backward = {a: input_tensor}
  
      # create batch
      input_tensor.shape = (1,) + input_tensor.shape
  
      forward_input = {a: input_tensor}
  
      unittest_helper(
          input_op,
          forward_input,
          expected_forward,
          expected_backward,
          device_id=device_id,
          precision=precision,
      )
  
imports: from __future__ import division
  import numpy
  import cntk
  import pytest
  from .ops_test_utils import unittest_helper, _test_unary_op, _test_binary_op, AA, precision, PRECISION_TO_TYPE, cntk_device
  import cntk
  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 2 for calling a global function with example usage: test_op_reshape_subshape(input_shape, replacement_shape, begin_axis, end_axis, expected_output_shape, device_id, precision) without return types