code: def test_series_reduction(
      setup, check_ref_counts, func_name, func_opts: FunctionOptions
  ):
      def compute(data, **kwargs):
          return getattr(data, func_name)(**kwargs)
  
      rs = np.random.RandomState(0)
      data = pd.Series(
          rs.randint(0, 8, (10,)),
          index=[str(i) for i in range(10)],
          name="a",
      )
      r = compute(md.Series(data))
      assert pytest.approx(compute(data)) == r.execute().fetch()
  
      r = compute(md.Series(data, chunk_size=6))
      assert pytest.approx(compute(data)) == r.execute().fetch()
  
      r = compute(md.Series(data, chunk_size=3))
      assert pytest.approx(compute(data)) == r.execute().fetch()
  
      r = compute(md.Series(data, chunk_size=4), axis="index")
      assert (
          pytest.approx(compute(data, axis="index"))
          == r.execute().fetch()
      )
  
      r = compute(md.Series(data, chunk_size=4), axis="index")
      assert (
          pytest.approx(compute(data, axis="index"))
          == r.execute().fetch()
      )
  
      data = pd.Series(rs.rand(20), name="a")
      data[0] = 0.1  # make sure not all elements are NAN
      data[data > 0.5] = np.nan
      r = compute(md.Series(data, chunk_size=3))
      assert pytest.approx(compute(data)) == r.execute().fetch()
  
      r = compute(md.Series(data, chunk_size=3), skipna=False)
      assert np.isnan(r.execute().fetch())
  
      if func_opts.has_min_count:
          r = compute(
              md.Series(data, chunk_size=3), skipna=False, min_count=2
          )
          assert np.isnan(r.execute().fetch())
  
          r = compute(md.Series(data, chunk_size=3), min_count=1)
          assert (
              pytest.approx(compute(data, min_count=1))
              == r.execute().fetch()
          )
  
          reduction_df5 = compute(
              md.Series(data, chunk_size=3), min_count=21
          )
          assert np.isnan(reduction_df5.execute().fetch())
  
      # test reduction on empty series
      data = pd.Series([], dtype=float, name="a")
      r = compute(md.Series(data))
      np.testing.assert_equal(r.execute().fetch(), compute(data))
  
imports: from typing import NamedTuple
  import numpy
  import pytest
  import pandas
  from ....None import dataframe
  from ....config import option_context
  from ....session import get_default_session
  from ....tests.core import require_cudf, require_cupy
  from ....utils import lazy_import, pd_release_version
  from ...None import CustomReduction, NamedAgg
  from ...base import to_gpu
label_desc: Use image node_id 2 for calling a global function with example usage: test_series_reduction(setup, check_ref_counts, func_name, func_opts) and returns: getattr