code: def test_detach_updated_grad():
      x = nd.ones((2, 2))
      dx = nd.zeros_like(x)
      y = nd.ones_like(x)
      dy = nd.zeros_like(x)
      mark_variables([x, y], [dx, dy])
      assert x._fresh_grad == False
      assert y._fresh_grad == False
  
      with record():
          x2 = x + 2
          y2 = x2 + y
          y2.backward()
      assert (dx.asnumpy() == 1).all()
      assert x._fresh_grad == True
      assert y._fresh_grad == True
  
      dx[:] = 0
      x._fresh_grad = False
      y._fresh_grad = False
      assert x._fresh_grad == False
      assert y._fresh_grad == False
      with record():
          x2 = x + 2
          x2 = x2.detach()
          y2 = x2 + y
          y2.backward()
      assert (dx.asnumpy() == 0).all()
      assert y._fresh_grad == True
      assert x._fresh_grad == False
  
imports: import functools
  import mxnet.ndarray
  from mxnet.ndarray import zeros_like
  from mxnet.autograd import *
  from mxnet.test_utils import *
  from common import xfail_when_nonstandard_decimal_separator
  from mxnet.test_utils import environment
  import pytest
label_desc: Use image node_id 10 for calling a global function with example usage: test_detach_updated_grad() without return types