code: def past_value(x, initial_state=None, time_step=1, name=""):
      """
      This function returns the past value w.r.t. ``x``. It is most often used when
      creating RNNs. The resulting tensor has the same shape as the input but is
      the previous logical sample. The ``time_step`` parameter is the number of steps
      to look into the past and is 1 by default. If there is no past value (i.e.
      the current sample is the first one in the tensor)  then the ``initial_state``
      value is returned.
  
      The initial state can be a constant (scalar or tensor), a learnable tensor
      or input data (which has a batch dimension, as needed for sequence-to-sequence models).
  
      Example:
          >>> # create example input: one sequence with 4 tensors of shape (3, 2)
          >>> from cntk.layers.typing import Tensor, Sequence
          >>> x = C.sequence.input_variable((3,2))
          >>> x0 = np.reshape(np.arange(24,dtype=np.float32),(1,4,3,2))
          >>> x0
          array([[[[  0.,   1.],
                   [  2.,   3.],
                   [  4.,   5.]],
          <BLANKLINE>
                  [[  6.,   7.],
                   [  8.,   9.],
                   [ 10.,  11.]],
          <BLANKLINE>
                  [[ 12.,  13.],
                   [ 14.,  15.],
                   [ 16.,  17.]],
          <BLANKLINE>
                  [[ 18.,  19.],
                   [ 20.,  21.],
                   [ 22.,  23.]]]], dtype=float32)
  
          >>> # this demonstrates how past_value shifts the sequence by one, padding with initial_state
          >>> y = C.sequence.past_value(x) # initial_state is 0 by default
          >>> y.eval({x:x0})
          [array([[[  0.,   0.],
                   [  0.,   0.],
                   [  0.,   0.]],
          <BLANKLINE>
                  [[  0.,   1.],
                   [  2.,   3.],
                   [  4.,   5.]],
          <BLANKLINE>
                  [[  6.,   7.],
                   [  8.,   9.],
                   [ 10.,  11.]],
          <BLANKLINE>
                  [[ 12.,  13.],
                   [ 14.,  15.],
                   [ 16.,  17.]]], dtype=float32)]
  
          >>> # here, we pass a the initial_state as input data (e.g. sequence-to-sequence)
          >>> s = C.input_variable((3,2))  # not a sequence, e.g. a final encoder hidden state
          >>> s0 = np.reshape(np.arange(6,dtype=np.float32)/2,(1,3,2))
          >>> s0
          array([[[ 0. ,  0.5],
                  [ 1. ,  1.5],
                  [ 2. ,  2.5]]], dtype=float32)
          >>> y = C.sequence.past_value(x, initial_state=s)
          >>> y.eval({x:x0, s:s0}) # same as the previous example except for the first time step
          [array([[[  0. ,   0.5],
                   [  1. ,   1.5],
                   [  2. ,   2.5]],
          <BLANKLINE>
                  [[  0. ,   1. ],
                   [  2. ,   3. ],
                   [  4. ,   5. ]],
          <BLANKLINE>
                  [[  6. ,   7. ],
                   [  8. ,   9. ],
                   [ 10. ,  11. ]],
          <BLANKLINE>
                  [[ 12. ,  13. ],
                   [ 14. ,  15. ],
                   [ 16. ,  17. ]]], dtype=float32)]
  
      Args:
          x: the tensor (or its name) from which the past value is obtained
          initial_state: tensor or scalar representing the initial value to be used when the input tensor is shifted in time.
          time_step (int): the number of time steps to look into the past (default 1)
          name (str, optional): the name of the Function instance in the network
  
      Returns:
          :class:`~cntk.ops.functions.Function`
      """
  
      from cntk.internal import sanitize_dtype_cntk
      from cntk.cntk_py import Constant, past_value
  
      if initial_state is None:
          initial_state = Constant.scalar(
              sanitize_dtype_cntk(x.dtype), 0.0
          )
      else:
          initial_state = sanitize_input(initial_state)
  
      x = sanitize_input(x)
      return past_value(x, initial_state, time_step, name)
  
imports: import numpy
  from cntk.internal import typemap, sanitize_input
  from cntk.internal.utils import get_data_type
  from ...axis import Axis
  from ...default_options import default_override_or
label_desc: Use image node_id 5 for calling a global function with example usage: past_value(x, initial_state, time_step, name) and returns: past_value