class_docstr: Tests for LAX-backed Numpy reduction operations.
class_docstr_tok: ["Tests","for","LAX-backed","Numpy","reduction","operations","."]
code: def testAverage(
      self, shape, dtype, axis, weights_shape, returned, keepdims
  ):
      rng = jtu.rand_default(self.rng())
      kwds = dict(returned=returned)
      if keepdims is not None:
          kwds["keepdims"] = keepdims
      if weights_shape is None:
          np_fun = lambda x: np.average(x, axis, **kwds)
          jnp_fun = lambda x: jnp.average(x, axis, **kwds)
          args_maker = lambda: [rng(shape, dtype)]
      else:
          np_fun = lambda x, weights: np.average(
              x, axis, weights, **kwds
          )
          jnp_fun = lambda x, weights: jnp.average(
              x, axis, weights, **kwds
          )
          args_maker = lambda: [
              rng(shape, dtype),
              rng(weights_shape, dtype),
          ]
      np_fun = jtu.promote_like_jnp(np_fun, inexact=True)
      tol = {
          dtypes.bfloat16: 2e-1,
          np.float16: 1e-2,
          np.float32: 1e-5,
          np.float64: 1e-12,
          np.complex64: 1e-5,
      }
      check_dtypes = shape is not jtu.PYTHON_SCALAR_SHAPE
      if (
          numpy_version == (1, 23, 0)
          and keepdims
          and weights_shape is not None
          and axis is not None
      ):
          # Known failure: https://github.com/numpy/numpy/issues/21850
          pass
      else:
          try:
              self._CheckAgainstNumpy(
                  np_fun,
                  jnp_fun,
                  args_maker,
                  check_dtypes=check_dtypes,
                  tol=tol,
              )
          except ZeroDivisionError:
              self.skipTest(
                  "don't support checking for ZeroDivisionError"
              )
      self._CompileAndCheck(
          jnp_fun,
          args_maker,
          check_dtypes=check_dtypes,
          rtol=tol,
          atol=tol,
      )
  
imports: import collections
  from functools import partial
  import itertools
  import unittest
  from absl.testing import absltest
  from absl.testing import parameterized
  import numpy
  import jax
  from jax import numpy
  from jax._src import config
  from jax._src import dtypes
  from jax._src import test_util
  from jax._src.util import NumpyComplexWarning
label_desc: Use image node_id 12 for calling the JaxNumpyReducerTests obj's underlying member method code with example usage: obj.testAverage(shape, dtype, axis, weights_shape, returned, keepdims) without return types