code: def average_pooling_nd(x, ksize, stride=None, pad=0, pad_value=0):
      """N-dimensionally spatial average pooling function.
  
      .. warning::
  
          This feature is experimental. The interface can change in the future.
  
      This function provides a N-dimensionally generalized version of
      :func:`~chainer.functions.average_pooling_2d`. This acts similarly to
      :func:`~chainer.functions.convolution_nd`, 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 tuple of ints): Size of pooling window. ``ksize=k`` and
              ``ksize=(k, k, ..., k)`` are equivalent.
          stride (int or tuple of ints or None): Stride of pooling applications.
              ``stride=s`` and ``stride=(s, s, ..., s)`` are equivalent. If
              ``None`` is specified, then it uses same stride as the pooling
              window size.
          pad (int or tuple of ints): Spatial padding width for the input array.
              ``pad=p`` and ``pad=(p, p, ..., p)`` are equivalent.
          pad_value (0 or None):
              Value to fill the padded region when calculating average.
              If ``None`` is specified, such region is ignored.
              The default value is ``0``, therefore the averages are biased
              towards zero.
  
      Returns:
          ~chainer.Variable: Output variable.
  
      .. note::
  
         This function currently does not support ``cover_all`` mode as
         :func:`max_pooling_nd`. Average pooling runs in non-cover-all mode.
  
      """
      ndim = len(x.shape[2:])
      return AveragePoolingND(
          ndim, ksize, stride=stride, pad=pad, pad_value=pad_value
      ).apply((x,))[0]
  
imports: import functools
  import operator
  import numpy
  import six
  import chainer
  from chainer import backend
  from chainer.backends import cuda
  from chainer import function_node
  from chainer.functions.pooling import average_pooling_nd_kernel
  from chainer.functions.pooling import pooling_nd
  from chainer.utils import conv
  from chainer.utils import conv_nd
  import chainerx
label_desc: Use image node_id 2 for calling a global function with example usage: average_pooling_nd(x, ksize, stride, pad, pad_value) and returns: AveragePoolingND