code: def test_rebalance_execution(setup):
      raw = pd.DataFrame(np.random.rand(10, 3), columns=list("abc"))
      df = from_pandas_df(raw)
  
      def _expect_count(n):
          def _tile_rebalance(op):
              tileable = yield from op.tile(op)
              assert len(tileable.chunks) == n
              return tileable
  
          return _tile_rebalance
  
      r = df.rebalance(num_partitions=3)
      extra_config = {
          "operand_tile_handlers": {
              DataFrameRebalance: _expect_count(3)
          }
      }
      result = r.execute(extra_config=extra_config).fetch()
      pd.testing.assert_frame_equal(result, raw)
  
      r = df.rebalance(factor=0.5)
      extra_config = {
          "operand_tile_handlers": {
              DataFrameRebalance: _expect_count(1)
          }
      }
      result = r.execute(extra_config=extra_config).fetch()
      pd.testing.assert_frame_equal(result, raw)
  
      # test worker has two cores
      r = df.rebalance()
      extra_config = {
          "operand_tile_handlers": {
              DataFrameRebalance: _expect_count(2)
          }
      }
      result = r.execute(extra_config=extra_config).fetch()
      pd.testing.assert_frame_equal(result, raw)
  
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 39 for calling a global function with example usage: test_rebalance_execution(setup) and returns: _tile_rebalance, tileable