code: def test_convert_dynamic_axis():
      # test fix batch size
      batch_size = 4
      a = C.parameter(shape=(batch_size, 2, 3), init=1)
      dynamic_a = C.to_batch(a)
      assert len(dynamic_a.dynamic_axes) == 1
      assert dynamic_a.shape == (2, 3)
  
      x = C.input_variable((2, 3))
      y = x * dynamic_a
  
      # test grad
      data = (
          np.arange(batch_size * 2 * 3)
          .reshape(batch_size, 2, 3)
          .astype("f")
      )
      assert np.array_equal(y.grad({x: data}, [a]), data)
  
      const_a = C.unpack_batch(y)
      assert len(const_a.dynamic_axes) == 0
      assert const_a.shape == (C.FreeDimension, 2, 3)
  
      f = C.assign(a, const_a)
      f.eval({x: data})
      assert np.array_equal(a.value, data)
  
      # test reshape with batch axis
      x = C.input_variable((2, 3))
      const_x = C.unpack_batch(x)
      assert len(const_x.dynamic_axes) == 0
      assert const_x.shape == (C.FreeDimension, 2, 3)
  
      const_y = C.reshape(const_x, (-1, 3))
      assert const_y.shape == (C.FreeDimension, 3)
      y = C.to_batch(const_y)
      assert len(y.dynamic_axes) == 1
      assert y.shape == (3,)
  
      z = y * 2
      expected = data.reshape((8, 3)) * 2
      assert np.array_equal(z.eval({x: data}), expected)
  
      # test inferred dimension
      x = C.input_variable((C.InferredDimension, 3))
      const_x = C.unpack_batch(x)
      assert len(const_x.dynamic_axes) == 0
      assert const_x.shape == (C.FreeDimension, C.InferredDimension, 3)
  
      const_y = const_x * 2
      y = C.to_batch(const_y)
      assert len(y.dynamic_axes) == 1
      assert y.shape == (C.InferredDimension, 3)
  
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 17 for calling a global function with example usage: test_convert_dynamic_axis() without return types