code: def test_cached_property():
      x = np.random.normal()
      x.attach_grad()
      scale = 0.1
  
      class Dummy(object):
          def __init__(self, x):
              super(Dummy, self).__init__()
              self.x = x
  
          @mgp.cached_property
          def y(self):
              return scale * self.x + 1
  
      with autograd.record():
          obj = Dummy(x)
          obj.y.backward()
      assert_almost_equal(x.grad.asnumpy(), scale * np.ones((1,)))
  
      class DummyBlock(HybridBlock):
          def forward(self, x):
              obj = Dummy(x)
              return obj.y
  
      x = np.random.normal()
      x.attach_grad()
      net = DummyBlock()
      with autograd.record():
          y = net(x)
          y.backward()
      assert_almost_equal(x.grad.asnumpy(), scale * np.ones((1,)))
  
      x = np.random.normal()
      x.attach_grad()
      net.hybridize()
      with autograd.record():
          y = net(x)
          y.backward()
      assert_almost_equal(x.grad.asnumpy(), scale * np.ones((1,)))
  
imports: import mxnet
  import numpy
  from mxnet import np, npx, autograd
  from mxnet import gluon
  import mxnet.gluon.probability
  from mxnet.gluon.probability import StochasticBlock, StochasticSequential
  from mxnet.gluon import HybridBlock
  from mxnet.test_utils import use_np, assert_almost_equal
  from numpy.testing import assert_array_equal
  import pytest
  import scipy.stats
  import scipy.special
  import itertools
  from numbers import Number
label_desc: Use image node_id 31 for calling a global function with example usage: test_cached_property() and returns: unknown, obj