code: def map_chunk(t, func, args=(), **kwargs):
      """
      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.
      **kwargs
          Additional keyword arguments to pass as keywords arguments to func.
  
      Returns
      -------
      Tensor
          Result of applying ``func`` to each chunk of the Tensor.
  
      Examples
      --------
      >>> import mars.tensor as mt
      >>> a = mt.array([[4, 9]] * 3)
      >>> a.execute()
      array([[4, 9],
             [4, 9],
             [4, 9]])
  
      Output dtype will be auto inferred.
  
      >>> a.map_chunk(lambda c: c * 0.5).execute()
      array([[2. , 4.5],
             [2. , 4.5],
             [2. , 4.5]])
  
      You can specify ``dtype`` by yourself if auto infer failed.
      """
      elementwise = kwargs.pop("elementwise", None)
      dtype = (
          np.dtype(kwargs.pop("dtype")) if "dtype" in kwargs else None
      )
      shape = kwargs.pop("shape", None)
      with_chunk_index = kwargs.pop("with_chunk_index", False)
  
      op = TensorMapChunk(
          func=func,
          args=args,
          kwargs=kwargs,
          elementwise=elementwise,
          with_chunk_index=with_chunk_index,
      )
      return op(t, dtype=dtype, shape=shape)
  
imports: import numpy
  from ...None import opcodes
  from ...core import ENTITY_TYPE, CHUNK_TYPE, recursive_tile
  from ...core.custom_log import redirect_custom_log
  from ...serialization.serializables import FunctionField, BoolField, TupleField, DictField
  from ...utils import enter_current_session, quiet_stdio, find_objects, replace_objects, has_unknown_shape
  from ..operands import TensorOperand, TensorOperandMixin
label_desc: Use image node_id 1 for calling a global function with example usage: map_chunk(t, func, args) and returns: op