code: def interpolate_bilinear_cpu(x, v, u, vw, uw):
      B, C, H, W = x.shape
      out_H, out_W = v.shape
  
      # Interpolation is done by each output panel (i.e. multi lines)
      # in order to better utilize CPU cache memory.
      lines = _infer_lines(B, C, H, W, out_H, out_W, 2, 2)
  
      vcol = numpy.empty((2, lines, out_W), dtype=v.dtype)
      ucol = numpy.empty((2, lines, out_W), dtype=u.dtype)
      wcol = numpy.empty((2, 2, lines, out_W), dtype=x.dtype)
  
      y = numpy.empty((B * C, out_H * out_W), dtype=x.dtype)
  
      for i in range(0, out_H, lines):
          l = min(lines, out_H - i)
          vcol = vcol[:, :l]
          ucol = ucol[:, :l]
          wcol = wcol[:, :, :l]
          i_end = i + l
  
          # indices
          vcol[0] = v[i:i_end]
          ucol[0] = u[i:i_end]
          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[0, 0] = (1 - uw) * (1 - vw)
          #   wcol[0, 1] = uw * (1 - vw)
          #   wcol[1, 0] = (1 - uw) * vw
          #   wcol[1, 1] = uw * vw
          wcol[0, 1] = uw[i:i_end]
          numpy.subtract(1, wcol[0, 1], out=wcol[0, 0])
          numpy.multiply(wcol[0], vw[i:i_end], out=wcol[1])
          wcol[0] -= wcol[1]
  
          # packing to the panel whose shape is (B, C, 2, 2, l, out_W)
          panel = x[:, :, vcol[:, None], ucol[None, :]]
  
          # interpolation
          panel = panel.reshape((B * C, 4, l * out_W))
          weights = wcol.reshape((4, l * out_W))
          iout = i * out_W
          iout_end = i_end * out_W
          numpy.einsum(
              "ijk,jk->ik", panel, weights, out=y[:, iout:iout_end]
          )
          del panel, weights
  
      return y.reshape((B, C, out_H, out_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 2 for calling a global function with example usage: interpolate_bilinear_cpu(x, v, u, vw, uw) and returns: y