class_docstr: Tests for LAX-backed Numpy reduction operations.
class_docstr_tok: ["Tests","for","LAX-backed","Numpy","reduction","operations","."]
code: def testVar(self, shape, dtype, out_dtype, axis, ddof, keepdims):
      rng = jtu.rand_default(self.rng())
      args_maker = self._GetArgsMaker(rng, [shape], [dtype])
  
      @jtu.ignore_warning(
          category=RuntimeWarning,
          message="Degrees of freedom <= 0 for slice.",
      )
      @jtu.ignore_warning(category=NumpyComplexWarning)
      def np_fun(x):
          # Numpy fails with bfloat16 inputs
          out = np.var(
              x.astype(
                  np.float32 if dtype == dtypes.bfloat16 else dtype
              ),
              dtype=np.float32
              if out_dtype == dtypes.bfloat16
              else out_dtype,
              axis=axis,
              ddof=ddof,
              keepdims=keepdims,
          )
          return out.astype(out_dtype)
  
      jnp_fun = partial(
          jnp.var,
          dtype=out_dtype,
          axis=axis,
          ddof=ddof,
          keepdims=keepdims,
      )
      tol = jtu.tolerance(
          out_dtype,
          {
              np.float16: 1e-1,
              np.float32: 1e-3,
              np.float64: 1e-3,
              np.complex128: 1e-6,
          },
      )
      if jnp.issubdtype(
          dtype, jnp.complexfloating
      ) and not jnp.issubdtype(out_dtype, jnp.complexfloating):
          self.assertRaises(ValueError, lambda: jnp_fun(*args_maker()))
      else:
          self._CheckAgainstNumpy(np_fun, jnp_fun, args_maker, tol=tol)
          self._CompileAndCheck(jnp_fun, args_maker, 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 13 for calling the JaxNumpyReducerTests obj's underlying member method code with example usage: obj.testVar(shape, dtype, out_dtype, axis, ddof, keepdims) and returns: out