code: def map_chunk(
      df_or_series, func, args=(), kwargs=None, skip_infer=False, **kw
  ):
      """
      Apply function to each chunk.
  
      Parameters
      ----------
      func : function
          Function to apply to each chunk.
      args : tuple
          Positional arguments to pass to func in addition to the array/series.
      kwargs: Dict
          Additional keyword arguments to pass as keywords arguments to func.
      skip_infer: bool, default False
          Whether infer dtypes when dtypes or output_type is not specified.
  
      Returns
      -------
      Series or DataFrame
          Result of applying ``func`` to each chunk of the DataFrame or Series.
  
      See Also
      --------
      DataFrame.apply : Perform any type of operations.
  
      Examples
      --------
      >>> import mars.dataframe as md
      >>> df = md.DataFrame([[4, 9]] * 3, columns=['A', 'B'])
      >>> df.execute()
         A  B
      0  4  9
      1  4  9
      2  4  9
  
      Output type including Series or DataFrame will be auto inferred.
  
      >>> df.map_chunk(lambda c: c['A'] + c['B']).execute()
      0    13
      1    13
      2    13
      dtype: int64
  
      You can specify ``output_type`` by yourself if auto infer failed.
  
      >>> import pandas as pd
      >>> import numpy as np
      >>> df['c'] = ['s1', 's2', 's3']
      >>> df.map_chunk(lambda c: pd.concat([c['A'], c['c'].str.slice(1).astype(int)], axis=1)).execute()
      Traceback (most recent call last):
      TypeError: Cannot determine `output_type`, you have to specify it as `dataframe` or `series`...
      >>> df.map_chunk(lambda c: pd.concat([c['A'], c['c'].str.slice(1).astype(int)], axis=1),
      >>>              output_type='dataframe', dtypes=pd.Series([np.dtype(object), np.dtype(int)])).execute()
         A  c
      0  4  1
      1  4  2
      2  4  3
      """
      output_type = kw.pop("output_type", None)
      output_types = kw.pop("output_types", None)
      object_type = kw.pop("object_type", None)
      output_types = validate_output_types(
          output_type=output_type,
          output_types=output_types,
          object_type=object_type,
      )
      output_type = output_types[0] if output_types else None
      if output_type:
          output_types = [output_type]
      elif skip_infer:
          output_types = [OutputType.df_or_series]
      index = kw.pop("index", None)
      dtypes = kw.pop("dtypes", None)
      with_chunk_index = kw.pop("with_chunk_index", False)
      if kw:  # pragma: no cover
          raise TypeError(f"Unknown kwargs: {kw}")
  
      op = DataFrameMapChunk(
          input=df_or_series,
          func=func,
          args=args,
          kwargs=kwargs or {},
          output_types=output_types,
          with_chunk_index=with_chunk_index,
      )
      return op(df_or_series, index=index, dtypes=dtypes)
  
imports: import numpy
  import pandas
  from ...None import opcodes
  from ...core import recursive_tile, get_output_types, ENTITY_TYPE, CHUNK_TYPE
  from ...core.custom_log import redirect_custom_log
  from ...serialization.serializables import KeyField, FunctionField, TupleField, DictField, BoolField, StringField, AnyField
  from ...utils import enter_current_session, has_unknown_shape, quiet_stdio, find_objects, replace_objects
  from ..operands import DataFrameOperand, DataFrameOperandMixin, OutputType
  from ..utils import build_df, build_empty_df, build_series, parse_index, validate_output_types, build_empty_series, clean_up_func, restore_func
label_desc: Use image node_id 1 for calling a global function with example usage: map_chunk(df_or_series, func, args, kwargs, skip_infer) and returns: op