code: def test_eval_again_with_prev_outputs_live(device_id):
      x = C.input_variable(2)
      dev = cntk_device(device_id)
      w1 = C.parameter(
          init=np.asarray([1], dtype=np.float32), device=dev
      )
      w2 = C.parameter(
          init=np.asarray([-1], dtype=np.float32), device=dev
      )
      out1 = x + w1
      out2 = x + w2
      op = C.combine([out1, out2])
  
      result1 = op.eval(
          {x: np.asarray([2, 5], dtype=np.float32)}, device=dev
      )
      assert np.array_equal(result1[out1.output], [[3, 6]])
      assert np.array_equal(result1[out2.output], [[1, 4]])
  
      result2 = op.eval(
          {x: np.asarray([[-1, 4], [-4, 7]], dtype=np.float32)},
          device=dev,
      )
      assert np.array_equal(result2[out1.output], [[0, 5], [-3, 8]])
      assert np.array_equal(result2[out2.output], [[-2, 3], [-5, 6]])
  
      # result1 should still be valid
      assert np.array_equal(result1[out1.output], [[3, 6]])
      assert np.array_equal(result1[out2.output], [[1, 4]])
  
      result1 = op.eval(
          {x: np.asarray([2, 5], dtype=np.float32)},
          device=dev,
          as_numpy=False,
      )
      assert np.array_equal(result1[out1.output].asarray(), [[3, 6]])
      assert np.array_equal(result1[out2.output].asarray(), [[1, 4]])
  
      result2 = op.eval(
          {x: np.asarray([[-1, 4], [-4, 7]], dtype=np.float32)},
          device=dev,
          as_numpy=False,
      )
      assert np.array_equal(
          result2[out1.output].asarray(), [[0, 5], [-3, 8]]
      )
      assert np.array_equal(
          result2[out2.output].asarray(), [[-2, 3], [-5, 6]]
      )
  
      # Accessing result1 now will cause an error since it was a temporary that
      # is now erased, due to the subsequent eval call
      with pytest.raises(RuntimeError):
          assert np.array_equal(
              result1[out1.output].asarray(), [[3, 6]]
          )
  
      grad_op = out1 + out2
      grad1 = grad_op.grad(
          {x: np.asarray([2, 5], dtype=np.float32)},
          wrt=[w1, w2],
          device=dev,
      )
      assert np.array_equal(grad1[w1], [2])
      assert np.array_equal(grad1[w2], [2])
  
      grad2 = grad_op.grad(
          {x: np.asarray([[-1, 4], [-4, 7]], dtype=np.float32)},
          wrt=[w1, w2],
          device=dev,
      )
      assert np.array_equal(grad2[w1], [4])
      assert np.array_equal(grad2[w2], [4])
  
      # grad1 should still be valid
      assert np.array_equal(grad1[w1], [2])
      assert np.array_equal(grad1[w2], [2])
  
      grad1 = grad_op.grad(
          {x: np.asarray([2, 5], dtype=np.float32)},
          wrt=[w1, w2],
          device=dev,
          as_numpy=False,
      )
      assert np.array_equal(grad1[w1].asarray(), [2])
      assert np.array_equal(grad1[w2].asarray(), [2])
  
      grad2 = grad_op.grad(
          {x: np.asarray([[-1, 4], [-4, 7]], dtype=np.float32)},
          wrt=[w1, w2],
          device=dev,
          as_numpy=False,
      )
      assert np.array_equal(grad2[w1].asarray(), [4])
      assert np.array_equal(grad2[w2].asarray(), [4])
  
      # Accessing grad1 now will cause an error since it was a temporary that
      # is now erased, due to the subsequent grad call
      with pytest.raises(RuntimeError):
          assert np.array_equal(grad1[w1].asarray(), [2])
  
imports: import numpy
  import os
  import pytest
  import cntk
  from .ops_test_utils import compare_lists_of_np_arrays, AA, cntk_device
  from cntk.io import MinibatchSource, CTFDeserializer, StreamDefs, StreamDef
label_desc: Use image node_id 25 for calling a global function with example usage: test_eval_again_with_prev_outputs_live(device_id) without return types