code: def test_multivariate_sampling(
      distr, params, dim, serialize_fn
  ) -> None:
      distr = distr(**params)
      distr = serialize_fn(distr)
      samples = distr.sample()
      assert samples.shape == (dim,)
      samples = distr.sample(num_samples=1)
      assert samples.shape == (1, dim)
      num_samples = 500_000
      samples = distr.sample(num_samples)
      assert samples.shape == (num_samples, dim)
  
      np_samples = samples.asnumpy()
  
      assert np.allclose(
          np_samples.mean(axis=0),
          distr.mean.asnumpy(),
          atol=1e-2,
          rtol=1e-2,
      )
  
      assert np.allclose(
          np.cov(np_samples.transpose()),
          distr.variance.asnumpy(),
          atol=1e-1,
          rtol=1e-1,
      )
  
file_path: gluonts/test/mx/distribution/test_distribution_sampling.py
imports: import mxnet
  import numpy
  import pytest
  from flaky import flaky
  from gluonts.core.serde import dump_json, load_json
  from gluonts.mx.model.tpp.distribution import Loglogistic, Weibull
  from gluonts.mx.distribution import Beta, Binned, Categorical, Dirichlet, DirichletMultinomial, Gamma, Gaussian, GenPareto, Laplace, MultivariateGaussian, NegativeBinomial, PiecewiseLinear, Poisson, StudentT, Uniform, ZeroAndOneInflatedBeta
  from gluonts.testutil import empirical_cdf
label_desc: Use image node_id 2 for calling a global function with example usage: test_multivariate_sampling(distr, params, dim, serialize_fn) without return types