code: def test_transform_execute(setup):
      cols = [chr(ord("A") + i) for i in range(10)]
      df_raw = pd.DataFrame(
          dict((c, [i**2 for i in range(20)]) for c in cols)
      )
  
      idx_vals = [chr(ord("A") + i) for i in range(20)]
      s_raw = pd.Series([i**2 for i in range(20)], index=idx_vals)
  
      def rename_fn(f, new_name):
          f.__name__ = new_name
          return f
  
      old_chunk_store_limit = options.chunk_store_limit
      try:
          options.chunk_store_limit = 20
  
          # DATAFRAME CASES
          df = from_pandas_df(df_raw, chunk_size=5)
  
          # test transform scenarios on data frames
          def f(s):
              if s[2] > 0:
                  return s
              else:
                  return pd.Series([s[2]] * len(s))
  
          with pytest.raises(TypeError):
              df.transform(f)
          r = df.transform(f, skip_infer=True)
          result = r.execute().fetch()
          expected = df_raw.transform(f)
          pd.testing.assert_frame_equal(result, expected)
  
          r = df.transform(lambda x: list(range(len(x))))
          result = r.execute().fetch()
          expected = df_raw.transform(lambda x: list(range(len(x))))
          pd.testing.assert_frame_equal(result, expected)
  
          r = df.transform(lambda x: list(range(len(x))), axis=1)
          result = r.execute().fetch()
          expected = df_raw.transform(
              lambda x: list(range(len(x))), axis=1
          )
          pd.testing.assert_frame_equal(result, expected)
  
          r = df.transform(["cumsum", "cummax", lambda x: x + 1])
          result = r.execute().fetch()
          expected = df_raw.transform(
              ["cumsum", "cummax", lambda x: x + 1]
          )
          pd.testing.assert_frame_equal(result, expected)
  
          fn_dict = OrderedDict(
              [
                  ("A", "cumsum"),
                  ("D", ["cumsum", "cummax"]),
                  ("F", lambda x: x + 1),
              ]
          )
          r = df.transform(fn_dict)
          result = r.execute().fetch()
          expected = df_raw.transform(fn_dict)
          pd.testing.assert_frame_equal(result, expected)
  
          r = df.transform(lambda x: x.iloc[:-1], _call_agg=True)
          result = r.execute().fetch()
          expected = df_raw.agg(lambda x: x.iloc[:-1])
          pd.testing.assert_frame_equal(result, expected)
  
          r = df.transform(
              lambda x: x.iloc[:-1], axis=1, _call_agg=True
          )
          result = r.execute().fetch()
          expected = df_raw.agg(lambda x: x.iloc[:-1], axis=1)
          pd.testing.assert_frame_equal(result, expected)
  
          fn_list = [
              rename_fn(
                  lambda x: x.iloc[1:].reset_index(drop=True), "f1"
              ),
              lambda x: x.iloc[:-1].reset_index(drop=True),
          ]
          r = df.transform(fn_list, _call_agg=True)
          result = r.execute().fetch()
          expected = df_raw.agg(fn_list)
          pd.testing.assert_frame_equal(result, expected)
  
          r = df.transform(lambda x: x.sum(), _call_agg=True)
          result = r.execute().fetch()
          expected = df_raw.agg(lambda x: x.sum())
          pd.testing.assert_series_equal(result, expected)
  
          fn_dict = OrderedDict(
              [
                  (
                      "A",
                      rename_fn(
                          lambda x: x.iloc[1:].reset_index(drop=True),
                          "f1",
                      ),
                  ),
                  (
                      "D",
                      [
                          rename_fn(
                              lambda x: x.iloc[1:].reset_index(
                                  drop=True
                              ),
                              "f1",
                          ),
                          lambda x: x.iloc[:-1].reset_index(drop=True),
                      ],
                  ),
                  ("F", lambda x: x.iloc[:-1].reset_index(drop=True)),
              ]
          )
          r = df.transform(fn_dict, _call_agg=True)
          result = r.execute().fetch()
          expected = df_raw.agg(fn_dict)
          pd.testing.assert_frame_equal(result, expected)
  
          # SERIES CASES
          series = from_pandas_series(s_raw, chunk_size=5)
  
          # test transform scenarios on series
          r = series.transform(lambda x: x + 1)
          result = r.execute().fetch()
          expected = s_raw.transform(lambda x: x + 1)
          pd.testing.assert_series_equal(result, expected)
  
          r = series.transform(["cumsum", lambda x: x + 1])
          result = r.execute().fetch()
          expected = s_raw.transform(["cumsum", lambda x: x + 1])
          pd.testing.assert_frame_equal(result, expected)
  
          # test transform on string dtype
          df_raw = pd.DataFrame(
              {"col1": ["str"] * 10, "col2": ["string"] * 10}
          )
          df = from_pandas_df(df_raw, chunk_size=3)
  
          r = df["col1"].transform(lambda x: x + "_suffix")
          result = r.execute().fetch()
          expected = df_raw["col1"].transform(lambda x: x + "_suffix")
          pd.testing.assert_series_equal(result, expected)
  
          r = df.transform(lambda x: x + "_suffix")
          result = r.execute().fetch()
          expected = df_raw.transform(lambda x: x + "_suffix")
          pd.testing.assert_frame_equal(result, expected)
  
          r = df["col2"].transform(
              lambda x: x + "_suffix", dtype=np.dtype("str")
          )
          result = r.execute().fetch()
          expected = df_raw["col2"].transform(lambda x: x + "_suffix")
          pd.testing.assert_series_equal(result, expected)
      finally:
          options.chunk_store_limit = old_chunk_store_limit
  
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 12 for calling a global function with example usage: test_transform_execute(setup) and returns: f, s, pd