code: def test_map_chunk_with_df_or_series_output(setup):
      raw = pd.DataFrame(
          np.random.rand(10, 5), columns=[f"col{i}" for i in range(5)]
      )
  
      df = from_pandas_df(raw, chunk_size=(5, 3))
  
      def f1(pdf):
          return pdf.iloc[2, :2]
  
      with pytest.raises(TypeError):
          df.map_chunk(f1)
  
      for kwargs in [
          dict(output_type="df_or_series"),
          dict(skip_infer=True),
      ]:
          res = df.map_chunk(f1, **kwargs)
          assert isinstance(res, DATAFRAME_OR_SERIES_TYPE)
          res = res.execute()
          assert res.data_type == "series"
          assert res.dtype == np.dtype("float")
          assert not ("dtypes" in res.data_params)
          assert res.shape == (4,)
          pd.testing.assert_series_equal(
              res.fetch(), pd.concat([raw.iloc[2, :2], raw.iloc[7, :2]])
          )
  
      def f2(pdf):
          return pdf.iloc[[0, 2], :2]
  
      with pytest.raises(TypeError):
          df.map_chunk(f2)
  
      res = df.map_chunk(f2, output_type="df_or_series")
      assert isinstance(res, DATAFRAME_OR_SERIES_TYPE)
      res = res.execute()
      assert res.data_type == "dataframe"
      pd.testing.assert_series_equal(res.dtypes, raw.dtypes[:2])
      assert not ("dtype" in res.data_params)
      assert res.shape == (4, 2)
      pd.testing.assert_frame_equal(
          res.fetch(),
          raw.iloc[[0, 2, 5, 7], :2],
      )
  
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 35 for calling a global function with example usage: test_map_chunk_with_df_or_series_output(setup) and returns: pdf, pdf