code: def test_cut_execution(setup):
      session = setup
  
      rs = np.random.RandomState(0)
      raw = rs.random(15) * 1000
      s = pd.Series(raw, index=[f"i{i}" for i in range(15)])
      bins = [10, 100, 500]
      if _interval_range_closed_arg:
          ii = pd.interval_range(10, 500, 3, closed="right")
      else:
          ii = pd.interval_range(10, 500, 3)
      labels = ["a", "b"]
  
      t = tensor(raw, chunk_size=4)
      series = from_pandas_series(s, chunk_size=4)
      iii = from_pandas_index(ii, chunk_size=2)
  
      # cut on Series
      r = cut(series, bins)
      result = r.execute().fetch()
      pd.testing.assert_series_equal(result, pd.cut(s, bins))
  
      r, b = cut(series, bins, retbins=True)
      r_result = r.execute().fetch()
      b_result = b.execute().fetch()
      r_expected, b_expected = pd.cut(s, bins, retbins=True)
      pd.testing.assert_series_equal(r_result, r_expected)
      np.testing.assert_array_equal(b_result, b_expected)
  
      # cut on tensor
      r = cut(t, bins)
      # result and expected is array whose dtype is CategoricalDtype
      result = r.execute().fetch()
      expected = pd.cut(raw, bins)
      assert len(result) == len(expected)
      for r, e in zip(result, expected):
          np.testing.assert_equal(r, e)
  
      # one chunk
      r = cut(
          s,
          tensor(bins, chunk_size=2),
          right=False,
          include_lowest=True,
      )
      result = r.execute().fetch()
      pd.testing.assert_series_equal(
          result, pd.cut(s, bins, right=False, include_lowest=True)
      )
  
      # test labels
      r = cut(t, bins, labels=labels)
      # result and expected is array whose dtype is CategoricalDtype
      result = r.execute().fetch()
      expected = pd.cut(raw, bins, labels=labels)
      assert len(result) == len(expected)
      for r, e in zip(result, expected):
          np.testing.assert_equal(r, e)
  
      r = cut(t, bins, labels=False)
      # result and expected is array whose dtype is CategoricalDtype
      result = r.execute().fetch()
      expected = pd.cut(raw, bins, labels=False)
      np.testing.assert_array_equal(result, expected)
  
      # test labels which is tensor
      labels_t = tensor(["a", "b"], chunk_size=1)
      r = cut(raw, bins, labels=labels_t, include_lowest=True)
      # result and expected is array whose dtype is CategoricalDtype
      result = r.execute().fetch()
      expected = pd.cut(raw, bins, labels=labels, include_lowest=True)
      assert len(result) == len(expected)
      for r, e in zip(result, expected):
          np.testing.assert_equal(r, e)
  
      # test labels=False
      r, b = cut(raw, ii, labels=False, retbins=True)
      # result and expected is array whose dtype is CategoricalDtype
      r_result, b_result = session.fetch(*session.execute(r, b))
      r_expected, b_expected = pd.cut(
          raw, ii, labels=False, retbins=True
      )
      for r, e in zip(r_result, r_expected):
          np.testing.assert_equal(r, e)
      pd.testing.assert_index_equal(b_result, b_expected)
  
      # test bins which is md.IntervalIndex
      r, b = cut(
          series, iii, labels=tensor(labels, chunk_size=1), retbins=True
      )
      r_result = r.execute().fetch()
      b_result = b.execute().fetch()
      r_expected, b_expected = pd.cut(
          s, ii, labels=labels, retbins=True
      )
      pd.testing.assert_series_equal(r_result, r_expected)
      pd.testing.assert_index_equal(b_result, b_expected)
  
      # test duplicates
      bins2 = [0, 2, 4, 6, 10, 10]
      r, b = cut(
          s,
          bins2,
          labels=False,
          retbins=True,
          right=False,
          duplicates="drop",
      )
      r_result = r.execute().fetch()
      b_result = b.execute().fetch()
      r_expected, b_expected = pd.cut(
          s,
          bins2,
          labels=False,
          retbins=True,
          right=False,
          duplicates="drop",
      )
      pd.testing.assert_series_equal(r_result, r_expected)
      np.testing.assert_array_equal(b_result, b_expected)
  
      # test ordered
      if pd.__version__ >= "1.1.0":
          bins3 = [10, 100, 500]
          r = cut(s, bins3, labels=labels, ordered=False)
          r_result = r.execute().fetch()
          r_expected = pd.cut(s, bins3, labels=labels, ordered=False)
          pd.testing.assert_series_equal(r_result, r_expected)
  
      # test integer bins
      r = cut(series, 3)
      result = r.execute().fetch()
      pd.testing.assert_series_equal(result, pd.cut(s, 3))
  
      r, b = cut(series, 3, right=False, retbins=True)
      r_result, b_result = session.fetch(*session.execute(r, b))
      r_expected, b_expected = pd.cut(s, 3, right=False, retbins=True)
      pd.testing.assert_series_equal(r_result, r_expected)
      np.testing.assert_array_equal(b_result, b_expected)
  
      # test min max same
      s2 = pd.Series([1.1] * 15)
      r = cut(s2, 3)
      result = r.execute().fetch()
      pd.testing.assert_series_equal(result, pd.cut(s2, 3))
  
      # test inf exist
      s3 = s2.copy()
      s3[-1] = np.inf
      with pytest.raises(ValueError):
          cut(s3, 3).execute()
  
imports: import random
  from collections import OrderedDict
  import numpy
  import pandas
  import pytest
  import mars
  from ....config import options, option_context
  from ....dataframe import DataFrame, Series
  from ....tensor import arange, tensor
  from ....tensor.random import rand
  from ....tests.core import require_cudf
  from ....utils import lazy_import, pd_release_version, no_default
  from ...None import eval, cut, qcut, get_dummies
  from ...core import DATAFRAME_OR_SERIES_TYPE
  from ...datasource.dataframe import from_pandas
  from ...datasource.series import from_pandas
  from ...datasource.index import from_pandas
  from ..None import to_gpu, to_cpu
  from ..bloom_filter import filter_by_bloom_filter
  from ..shift import _enable_no_default, _with_column_freq_bug
  from ..to_numeric import to_numeric
  from ..rebalance import DataFrameRebalance
label_desc: Use image node_id 17 for calling a global function with example usage: test_cut_execution(setup) without return types