code: def test_series_level_reduction(
      setup, func_name, func_opts: FunctionOptions
  ):
      def compute(data, **kwargs):
          return getattr(data, func_name)(**kwargs)
  
      rs = np.random.RandomState(0)
      idx = pd.MultiIndex.from_arrays(
          [
              [str(i) for i in range(100)],
              rs.choice(["A", "B"], size=(100,)),
          ],
          names=["a", "b"],
      )
      data = pd.Series(rs.randint(0, 8, size=(100,)), index=idx)
  
      r = compute(
          md.Series(data, chunk_size=13), level=1, method="tree"
      )
      pd.testing.assert_series_equal(
          compute(data, level=1).sort_index(),
          r.execute().fetch().sort_index(),
      )
  
      # test null
      data = pd.Series(rs.rand(100), name="a", index=idx)
      idx_df = idx.to_frame()
      data[data > 0.5] = np.nan
      data[int(idx_df[idx_df.b == "A"].iloc[0, 0])] = 0.1
      data[int(idx_df[idx_df.b == "B"].iloc[0, 0])] = 0.1
  
      r = compute(
          md.Series(data, chunk_size=13), level=1, method="tree"
      )
      pd.testing.assert_series_equal(
          compute(data, level=1).sort_index(),
          r.execute().fetch().sort_index(),
      )
  
      r = compute(
          md.Series(data, chunk_size=13),
          level=1,
          skipna=False,
          method="tree",
      )
      pd.testing.assert_series_equal(
          compute(data, level=1, skipna=False).sort_index(),
          r.execute().fetch().sort_index(),
      )
  
      if func_opts.has_min_count:
          r = compute(
              md.Series(data, chunk_size=13),
              min_count=1,
              level=1,
              method="tree",
          )
          pd.testing.assert_series_equal(
              compute(data, min_count=1, level=1).sort_index(),
              r.execute().fetch().sort_index(),
          )
  
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 3 for calling a global function with example usage: test_series_level_reduction(setup, func_name, func_opts) and returns: getattr