code: def test_retain_grad_drop_grad_gluon():
      class CompBlock(mx.gluon.HybridBlock):
          def __init__(self):
              super().__init__()
              self.marked_var = None
  
          def forward(self, a, b):
              out1 = a * b
              out2 = out1 * a
              self.marked_var = out1
              return out2
  
      x = mx.np.array([1, 2, 3, 4])
      y = mx.np.array([5, 6, 7, 8])
      x.attach_grad()
      y.attach_grad()
      block2 = CompBlock()
      block2.initialize()
      # block2.hybridize()
      with mx.autograd.record():
          z = block2(x, y)
      u = block2.marked_var
      u.attach_grad()
      z.attach_grad()
      z.backward(retain_graph=True)
  
      assert (u.grad == x).all()
      assert (z.grad == mx.np.array([1, 1, 1, 1])).all()
      assert (x.grad == 2 * x * y).all()
      assert (y.grad == x * x).all()
  
      u.drop_grad()
      z.drop_grad()
      y.drop_grad()
      z.backward()
  
      assert u.grad is None and z.grad is None and y.grad is None
      assert (x.grad == 2 * x * y).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 23 for calling a global function with example usage: test_retain_grad_drop_grad_gluon() and returns: out2