code: def test_is_valid(device_id):
      a = C.input_variable((2,), needs_gradient=True)
      b = a * a
      a0 = np.array([1, 2], dtype=np.float32)
      g = b.grad({a: a0}, as_numpy=False)
      g2 = b.grad({a: a0}, as_numpy=False)
      assert g.is_valid == False
      assert g2.is_valid == True
  
imports: import pytest
  import numpy
  import scipy.sparse
  import cntk
  from cntk.ops.tests.ops_test_utils import cntk_device
  from cntk.internal import _value_as_sequence_or_array
  from cntk import asvalue
  from cntk.tests.test_utils import _to_dense, _to_csr
label_desc: Use image node_id 13 for calling a global function with example usage: test_is_valid(device_id) without return types