code: def forward_gpu(self, gy):
      if self._used_cudnn:
          (x,) = self.apool2d.get_retained_inputs()
          return self.apool2d.backward_gpu((x.data,), gy)
      n, c, h, w = self._in_shape
      y_h, y_w = gy[0].shape[2:]
      gx = cuda.cupy.empty(self._in_shape, self._in_dtype)
      coeff = 1.0 / (self.kh * self.kw)
      cuda.elementwise(
          "raw T gy, 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 gx",
          """
                 int c0 = i / (h * w);
                 int y  = i / w % h + ph;
                 int x  = i % w + pw;
                 int out_y_0 = max(0,     (y - kh + sy) / sy);
                 int out_y_1 = min(out_h, (y      + sy) / sy);
                 int out_x_0 = max(0,     (x - kw + sx) / sx);
                 int out_x_1 = min(out_w, (x      + sx) / sx);
                 int hc0  = out_h * c0;
  
                 T val = 0;
                 for (int out_y = out_y_0; out_y < out_y_1; ++out_y) {
                   for (int out_x = out_x_0; out_x < out_x_1; ++out_x) {
                     val = val + gy[out_x + out_w * (out_y + hc0)];
                   }
                 }
                 gx = val * coeff;
              """,
          "avg_pool_bwd",
      )(
          gy[0].reduced_view(),
          h,
          w,
          y_h,
          y_w,
          self.kh,
          self.kw,
          self.sy,
          self.sx,
          self.ph,
          self.pw,
          coeff,
          gx,
      )
      return (gx,)
  
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 4 for calling the AveragePooling2DGrad obj's underlying member method code with example usage: obj.forward_gpu(gy) and returns: gx, self