code: def test_nan_reduction(setup):
      raw = np.random.choice(
          a=[0, 1, np.nan], size=(10, 10), p=[0.3, 0.4, 0.3]
      )
  
      arr = tensor(raw, chunk_size=6)
  
      assert np.nansum(raw) == nansum(arr).execute().fetch()
      assert np.nanprod(raw) == nanprod(arr).execute().fetch()
      assert np.nanmax(raw) == nanmax(arr).execute().fetch()
      assert np.nanmin(raw) == nanmin(arr).execute().fetch()
      assert np.nanmean(raw) == nanmean(arr).execute().fetch()
      assert (
          pytest.approx(np.nanvar(raw)) == nanvar(arr).execute().fetch()
      )
      assert (
          pytest.approx(np.nanvar(raw, ddof=1))
          == nanvar(arr, ddof=1).execute().fetch()
      )
      assert (
          pytest.approx(np.nanstd(raw)) == nanstd(arr).execute().fetch()
      )
      assert (
          pytest.approx(np.nanstd(raw, ddof=1))
          == nanstd(arr, ddof=1).execute().fetch()
      )
  
      arr = tensor(raw, chunk_size=10)
  
      assert np.nansum(raw) == nansum(arr).execute().fetch()
      assert np.nanprod(raw) == nanprod(arr).execute().fetch()
      assert np.nanmax(raw) == nanmax(arr).execute().fetch()
      assert np.nanmin(raw) == nanmin(arr).execute().fetch()
      assert np.nanmean(raw) == nanmean(arr).execute().fetch()
      assert (
          pytest.approx(np.nanvar(raw)) == nanvar(arr).execute().fetch()
      )
      assert (
          pytest.approx(np.nanvar(raw, ddof=1))
          == nanvar(arr, ddof=1).execute().fetch()
      )
      assert (
          pytest.approx(np.nanstd(raw)) == nanstd(arr).execute().fetch()
      )
      assert (
          pytest.approx(np.nanstd(raw, ddof=1))
          == nanstd(arr, ddof=1).execute().fetch()
      )
  
      raw = np.random.random((10, 10))
      raw[:3, :3] = np.nan
      arr = tensor(raw, chunk_size=6)
      assert np.nanargmin(raw) == nanargmin(arr).execute().fetch()
      assert np.nanargmax(raw) == nanargmax(arr).execute().fetch()
  
      raw = np.full((10, 10), np.nan)
      arr = tensor(raw, chunk_size=6)
  
      assert 0 == nansum(arr).execute().fetch()
      assert 1 == nanprod(arr).execute().fetch()
      assert np.isnan(nanmax(arr).execute().fetch())
      assert np.isnan(nanmin(arr).execute().fetch())
      assert np.isnan(nanmean(arr).execute().fetch())
      with pytest.raises(ValueError):
          _ = nanargmin(arr).execute()  # noqa: F841
      with pytest.raises(ValueError):
          _ = nanargmax(arr).execute()  # noqa: F841
  
      raw = sps.random(10, 10, density=0.1, format="csr")
      raw[:3, :3] = np.nan
      arr = tensor(raw, chunk_size=6)
  
      assert (
          pytest.approx(np.nansum(raw.A))
          == nansum(arr).execute().fetch()
      )
      assert (
          pytest.approx(np.nanprod(raw.A))
          == nanprod(arr).execute().fetch()
      )
      assert (
          pytest.approx(np.nanmax(raw.A))
          == nanmax(arr).execute().fetch()
      )
      assert (
          pytest.approx(np.nanmin(raw.A))
          == nanmin(arr).execute().fetch()
      )
      assert (
          pytest.approx(np.nanmean(raw.A))
          == nanmean(arr).execute().fetch()
      )
      assert (
          pytest.approx(np.nanvar(raw.A))
          == nanvar(arr).execute().fetch()
      )
      assert (
          pytest.approx(np.nanvar(raw.A, ddof=1))
          == nanvar(arr, ddof=1).execute().fetch()
      )
      assert (
          pytest.approx(np.nanstd(raw.A))
          == nanstd(arr).execute().fetch()
      )
      assert (
          pytest.approx(np.nanstd(raw.A, ddof=1))
          == nanstd(arr, ddof=1).execute().fetch()
      )
  
      arr = nansum(1)
      assert arr.execute().fetch() == 1
  
imports: import numpy
  import scipy.sparse
  import pytest
  from ....utils import ignore_warning
  from ...datasource import ones, tensor
  from ..None import mean, nansum, nanmax, nanmin, nanmean, nanprod, nanargmax, nanargmin, nanvar, nanstd, count_nonzero, allclose, array_equal, var, std, nancumsum, nancumprod
label_desc: Use image node_id 8 for calling a global function with example usage: test_nan_reduction(setup) without return types