code: def test_compose_transform():
      class TestComposeTransform(HybridBlock):
          def __init__(self, func):
              super(TestComposeTransform, self).__init__()
              self._func = func
  
          def forward(self, loc, scale, *args):
              # Generate a log_normal distribution.
              std_normal = mgp.Normal(
                  np.zeros_like(loc), np.ones_like(scale)
              )
              transforms = mgp.ComposeTransform(
                  [
                      mgp.AffineTransform(loc=0, scale=scale),
                      mgp.AffineTransform(loc=loc, scale=1),
                      mgp.ExpTransform(),
                  ]
              )
              transformed_normal = mgp.TransformedDistribution(
                  std_normal, transforms
              )
              if len(args) == 0:
                  return getattr(transformed_normal, self._func)
              return getattr(transformed_normal, self._func)(*args)
  
      shapes = [(1,), (2, 3), 6]
      # Test log_prob
      for shape, hybridize in itertools.product(shapes, [True, False]):
          loc = np.random.uniform(-1, 1, shape)
          loc.attach_grad()
          scale = np.random.uniform(0.5, 1.5, shape)
          scale.attach_grad()
          samples = np.random.uniform(1, 2, size=shape)
          net = TestComposeTransform("log_prob")
          if hybridize:
              net.hybridize()
          with autograd.record():
              mx_out = net(loc, scale, samples)
          np_out = ss.lognorm(
              s=scale.asnumpy(), scale=np.exp(loc).asnumpy()
          ).logpdf(samples.asnumpy())
          assert_almost_equal(
              mx_out.asnumpy(),
              np_out,
              atol=1e-4,
              rtol=1e-3,
              use_broadcast=False,
          )
  
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 30 for calling a global function with example usage: test_compose_transform() and returns: getattr, getattr