code: def test_independent():
      class TestIndependent(HybridBlock):
          def __init__(self, event_dim, func):
              super(TestIndependent, self).__init__()
              self._event_dim = event_dim
              self._func = func
  
          def forward(self, logit, *args):
              base_dist = mgp.Bernoulli(logit=logit)
              reshaped_dist = mgp.Independent(
                  base_dist, self._event_dim
              )
              return getattr(reshaped_dist, self._func)(*args)
  
      event_shapes = [(1,), (4,), (2, 2)]
      batch_shapes = [(2, 3), (2,)]
      for batch_shape, event_shape in itertools.product(
          batch_shapes, event_shapes
      ):
          for hybridize in [False, True]:
              for func in ["log_prob"]:
                  full_shape = batch_shape + event_shape
                  logit = np.random.normal(0, 2, size=full_shape)
                  samples = np.round(np.random.uniform(size=full_shape))
                  net = TestIndependent(len(event_shape), func)
                  if hybridize:
                      net.hybridize()
                  mx_out = net(logit, samples)
                  assert mx_out.shape == batch_shape
  
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 32 for calling a global function with example usage: test_independent() and returns: getattr