class_docstr: This is a medium test due to the moments computation taking some time.
class_docstr_tok: ["This","is","a","medium","test","due","to","the","moments","computation","taking","some","time","."]
code: def _testMoments(self, dt):
      try:
          from scipy import stats  # pylint: disable=g-import-not-at-top
      except ImportError as e:
          tf_logging.warn("Cannot test moments: %s" % e)
          return
  
      # The moments test is a z-value test.  This is the largest z-value
      # we want to tolerate. Since the z-test approximates a unit normal
      # distribution, it should almost definitely never exceed 6.
      z_limit = 6.0
  
      for stride in 0, 1, 4, 17:
          alphas = [0.2, 1.0, 3.0]
          if dt == dtypes.float64:
              alphas = [0.01] + alphas
          for alpha in alphas:
              for scale in 9, 17:
                  # Gamma moments only defined for values less than the scale param.
                  max_moment = min(6, scale // 2)
                  sampler = self._Sampler(
                      20000, alpha, 1 / scale, dt, seed=12345
                  )
                  z_scores = util.test_moment_matching(
                      sampler(),
                      max_moment,
                      stats.gamma(alpha, scale=scale),
                      stride=stride,
                  )
                  self.assertAllLess(z_scores, z_limit)
  
imports: import numpy
  from tensorflow.python.eager import context
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import random_seed
  from tensorflow.python.framework import test_util
  from tensorflow.python.kernel_tests.random import util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import random_ops
  from tensorflow.python.platform import test
  from tensorflow.python.platform import tf_logging
label_desc: Use image node_id 7 for calling the RandomGammaTest obj's underlying member method code with example usage: obj._testMoments(dt) without return types