code: def interpolate_grad_bilinear_cpu(gy, v, u, vw, uw, H, W):
      B, C, out_H, out_W = gy.shape
  
      # indices
      vcol = numpy.empty((2, out_H, out_W), dtype=v.dtype)
      ucol = numpy.empty((2, out_H, out_W), dtype=u.dtype)
      vcol[0] = v
      ucol[0] = u
      numpy.add(vcol[0], 1, out=vcol[1])
      numpy.add(ucol[0], 1, out=ucol[1])
      numpy.minimum(vcol[1], H - 1, out=vcol[1])
      numpy.minimum(ucol[1], W - 1, out=ucol[1])
  
      # weights
      wcol = numpy.empty((2, 2, out_H, out_W), dtype=gy.dtype)
      wcol[0, 1] = uw
      numpy.subtract(1, wcol[0, 1], out=wcol[0, 0])
      numpy.multiply(wcol[0], vw, out=wcol[1])
      wcol[0] -= wcol[1]
  
      # grad
      gycol = gy.reshape((B * C, 1, 1, out_H, out_W)) * wcol
  
      # ravel everything and use `bincount`
      indices = (vcol[:, None] * W + ucol[None, :]).ravel()
      offsets = numpy.arange(0, B * C * H * W, H * W, dtype=v.dtype)
      indices = (offsets[:, None] + indices).ravel()
      gx = numpy.bincount(
          indices, weights=gycol.ravel(), minlength=(B * C * H * W)
      )
      gx = gx.astype(gy.dtype, copy=False)
  
      return gx.reshape((B, C, H, W))
  
imports: from __future__ import division
  import numpy
  from chainer import backend
  from chainer.backends import cuda
  from chainer import function_node
  from chainer.utils import type_check
label_desc: Use image node_id 4 for calling a global function with example usage: interpolate_grad_bilinear_cpu(gy, v, u, vw, uw, H, W) and returns: gx