class_docstr: Average pooling over a set of 2d planes.
code: def forward_gpu(self, x):
      if chainer.should_use_cudnn(">=auto"):
          self.retain_inputs((0,))
          return super(AveragePooling2D, self).forward_gpu(x)
  
      self._in_shape = x[0].shape
      self._in_dtype = x[0].dtype
  
      n, c, h, w = x[0].shape
      y_h = conv.get_conv_outsize(h, self.kh, self.sy, self.ph)
      y_w = conv.get_conv_outsize(w, self.kw, self.sx, self.pw)
      y = cuda.cupy.empty((n, c, y_h, y_w), dtype=x[0].dtype)
      coeff = 1.0 / (self.kh * self.kw)
      kern = cuda.elementwise(
          "raw T in, int32 h, int32 w,"
          "int32 out_h, int32 out_w, int32 kh, int32 kw,"
          "int32 sy, int32 sx, int32 ph, int32 pw, T coeff",
          "T out",
          """
              int c0    = i / (out_h * out_w);
              int out_y = i / out_w % out_h;
              int out_x = i % out_w;
              int in_y_0 = max(0, out_y * sy - ph);
              int in_y_1 = min(h, out_y * sy + kh - ph);
              int in_x_0 = max(0, out_x * sx - pw);
              int in_x_1 = min(w, out_x * sx + kw - pw);
  
              T val = 0;
              for (int y = in_y_0; y < in_y_1; ++y) {
                int offset_y = w * (y + h * c0);
                for (int x = in_x_0; x < in_x_1; ++x) {
                  val = val + in[x + offset_y];
                }
              }
              out = val * coeff;
              """,
          "avg_pool_fwd",
      )
      kern(
          x[0].reduced_view(),
          h,
          w,
          y_h,
          y_w,
          self.kh,
          self.kw,
          self.sy,
          self.sx,
          self.ph,
          self.pw,
          coeff,
          y,
      )
      return (y,)
  
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 3 for calling the AveragePooling2D obj's underlying member method code with example usage: obj.forward_gpu(x) and returns: y, super