code: def max_pooling_2d(
      x, ksize, stride=None, pad=0, cover_all=True, return_indices=False
  ):
      """Spatial max pooling function.
  
      This function acts similarly to :func:`~chainer.functions.convolution_2d`,
      but it computes the maximum of input spatial patch for each channel without
      any parameter instead of computing the inner products.
  
      Args:
          x (~chainer.Variable): Input variable.
          ksize (int or pair of ints): Size of pooling window. ``ksize=k`` and
              ``ksize=(k, k)`` are equivalent.
          stride (int or pair of ints or None): Stride of pooling applications.
              ``stride=s`` and ``stride=(s, s)`` are equivalent. If ``None`` is
              specified, then it uses same stride as the pooling window size.
          pad (int or pair of ints): Spatial padding width for the input array.
              ``pad=p`` and ``pad=(p, p)`` are equivalent.
          cover_all (bool): If ``True``, all spatial locations are pooled into
              some output pixels. It may make the output size larger.
          return_indices (bool): If ``True``, pooling indices array is returned
              together with the output variable. The returned indices are
              expected for use by :func:`chainer.functions.upsampling_2d`.
              Note that cuDNN will not be used for this function if
              ``return_indices`` is set to ``True``, as cuDNN does not return
              indices information.
  
      Returns:
          ~chainer.Variable or tuple:
              When ``return_indices`` is ``False`` (default), returns the output
              variable.
              When ``True``, returns the tuple of the output variable and
              pooling indices (:ref:`ndarray`). Pooling indices will be on the
              same device as the input.
  
      """
      if len(x.shape[2:]) != 2:
          raise ValueError(
              "The number of dimensions under channel dimension of the input "
              "'x' should be 2. But the actual ndim was {}.".format(
                  len(x.shape[2:])
              )
          )
      return max_pooling_nd(
          x, ksize, stride, pad, cover_all, return_indices
      )
  
imports: import functools
  from operator import mul
  import numpy
  import six
  import chainer
  from chainer import backend
  from chainer.backends import cuda
  from chainer.backends import intel64
  from chainer import configuration
  from chainer import function_node
  from chainer.functions.pooling import max_pooling_nd_kernel
  from chainer.functions.pooling import pooling_nd
  from chainer.utils import conv_nd
  import chainerx
label_desc: Use image node_id 3 for calling a global function with example usage: max_pooling_2d(x, ksize, stride, pad, cover_all, return_indices) and returns: max_pooling_nd