code: def average_pooling_2d(x, ksize, stride=None, pad=0):
      """Spatial average pooling function.
  
      This function acts similarly to :func:`~chainer.functions.convolution_2d`,
      but it computes the average 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.
  
      Returns:
          ~chainer.Variable: Output variable.
  
      .. note::
  
         This function currently does not support ``cover_all`` mode as
         :func:`max_pooling_2d`. Average pooling runs in non-cover-all mode.
  
      .. note::
  
         The values in the padded region is treated as 0, leading the averages
         biased towards zero.
         To obtain unbiased averages, use :func:`average_pooling_nd` with
         ``pad_value=None``.
  
      """
      if backend.get_array_module(x) is chainerx:
          return average_pooling_nd.average_pooling_nd(
              x, ksize, stride, pad
          )
      return AveragePooling2D(ksize, stride, pad, False).apply((x,))[0]
  
imports: import numpy
  import chainer
  from chainer import backend
  from chainer.backends import cuda
  from chainer.backends import intel64
  from chainer import function_node
  from chainer.functions.pooling import average_pooling_nd
  from chainer.functions.pooling import pooling_2d
  from chainer.utils import conv
  import chainerx
label_desc: Use image node_id 1 for calling a global function with example usage: average_pooling_2d(x, ksize, stride, pad) and returns: AveragePooling2D, average_pooling_nd