code: def test_retain_grad_drop_grad():
      x = nd.array([1, 2, 3, 4])
      x.attach_grad()
      y = nd.array([5, 6, 7, 8])
      y.attach_grad()
  
      with mx.autograd.record():
          u = x * y
          z = u * x
  
      u.attach_grad()
      z.attach_grad()
      out_grad = nd.array([10, 10, 10, 10])
      z.backward(out_grad, retain_graph=True)
  
      assert (u.grad == out_grad * x).asnumpy().all()
      assert (z.grad == out_grad).asnumpy().all()
      assert (x.grad == out_grad * 2 * x * y).asnumpy().all()
      assert (y.grad == out_grad * x * x).asnumpy().all()
  
      u.drop_grad()
      z.drop_grad()
      y.drop_grad()
      out_grad = nd.array([0.1, 0.1, 0.1, 0.1])
      z.backward(out_grad)
  
      assert u.grad is None and z.grad is None and y.grad is None
      assert (x.grad == out_grad * 2 * x * y).asnumpy().all()
  
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 22 for calling a global function with example usage: test_retain_grad_drop_grad() without return types