code: def test_moments(distname, arg):
      try:
          distfn = getattr(stats, distname)
      except TypeError:
          distfn = distname
          distname = "sample distribution"
      m, v, s, k = distfn.stats(*arg, moments="mvsk")
      check_normalization(distfn, arg, distname)
  
      # compare `stats` and `moment` methods
      check_moment(distfn, arg, m, v, distname)
      check_mean_expect(distfn, arg, m, distname)
      check_var_expect(distfn, arg, m, v, distname)
      check_skew_expect(distfn, arg, m, v, s, distname)
      if distname not in ["zipf", "yulesimon", "betanbinom"]:
          check_kurt_expect(distfn, arg, m, v, k, distname)
  
      # frozen distr moments
      check_moment_frozen(distfn, arg, m, 1)
      check_moment_frozen(distfn, arg, v + m * m, 2)
  
imports: import numpy.testing
  from numpy.testing import assert_allclose
  import numpy
  import pytest
  from scipy import stats
  from .common_tests import check_normalization, check_moment, check_mean_expect, check_var_expect, check_skew_expect, check_kurt_expect, check_entropy, check_private_entropy, check_edge_support, check_named_args, check_random_state_property, check_pickling, check_rvs_broadcast, check_freezing
  from scipy.stats._distr_params import distdiscrete, invdistdiscrete
  from scipy.stats._distn_infrastructure import rv_discrete_frozen
label_desc: Use image node_id 3 for calling a global function with example usage: test_moments(distname, arg) without return types