code: def test_op_past_value(
      input_size, time_step, initial_state, device_id, precision
  ):
      dt = PRECISION_TO_TYPE[precision]
      total_elements = np.product(input_size)
  
      x = np.arange(total_elements, dtype=dt).reshape(input_size)
  
      expected_forward = np.zeros_like(x, dtype=dt)
  
      for seq_idx in range(input_size[0]):
          expected_forward[seq_idx] = np.roll(
              AA(x[seq_idx], dtype=dt), time_step, axis=0
          )
          expected_forward[seq_idx, 0:time_step] = initial_state
  
      elem_shape = input_size[2:]
      a = sequence.input_variable(
          shape=elem_shape,
          dtype=sanitize_dtype_cntk(precision),
          needs_gradient=True,
          name="a",
      )
  
      backward = np.ones_like(x, dtype=dt)
      for seq_idx in range(input_size[0]):
          for t in range(time_step):
              backward[seq_idx, -1 - t] = 0.0
  
      expected_backward = {a: backward}
  
      init = parameter(
          init=AA(initial_state, dtype=dt),
          device=cntk_device(device_id),
      )
  
      input_op_input = sequence.past_value(a, init, time_step)
  
      unittest_helper(
          input_op_input,
          x,
          expected_forward,
          expected_backward,
          device_id=device_id,
          precision=precision,
      )
  
file_path: CNTK/bindings/python/cntk/ops/tests/recurrent_test.py
imports: from __future__ import division
  import numpy
  import pytest
  from .ops_test_utils import _test_binary_op, AA, precision, PRECISION_TO_TYPE, unittest_helper, sanitize_dtype_cntk, cntk_device
  from ..None import parameter, sequence
label_desc: Use image node_id 2 for calling a global function with example usage: test_op_past_value(input_size, time_step, initial_state, device_id, precision) without return types