code: def _interpolate(im, x, y, out_height, out_width, border_mode):
      # *_f are floats
      num_batch, height, width, channels = im.shape
      height_f = T.cast(height, theano.config.floatX)
      width_f = T.cast(width, theano.config.floatX)
  
      # scale coordinates from [-1, 1] to [0, width/height - 1]
      x = (x + 1) / 2 * (width_f - 1)
      y = (y + 1) / 2 * (height_f - 1)
  
      # obtain indices of the 2x2 pixel neighborhood surrounding the coordinates;
      # we need those in floatX for interpolation and in int64 for indexing.
      x0_f = T.floor(x)
      y0_f = T.floor(y)
      x1_f = x0_f + 1
      y1_f = y0_f + 1
  
      # for indexing, we need to take care of the border mode for outside pixels.
      if border_mode == "nearest":
          x0 = T.clip(x0_f, 0, width_f - 1)
          x1 = T.clip(x1_f, 0, width_f - 1)
          y0 = T.clip(y0_f, 0, height_f - 1)
          y1 = T.clip(y1_f, 0, height_f - 1)
      elif border_mode == "mirror":
          w = 2 * (width_f - 1)
          x0 = T.minimum(x0_f % w, -x0_f % w)
          x1 = T.minimum(x1_f % w, -x1_f % w)
          h = 2 * (height_f - 1)
          y0 = T.minimum(y0_f % h, -y0_f % h)
          y1 = T.minimum(y1_f % h, -y1_f % h)
      elif border_mode == "wrap":
          x0 = T.mod(x0_f, width_f)
          x1 = T.mod(x1_f, width_f)
          y0 = T.mod(y0_f, height_f)
          y1 = T.mod(y1_f, height_f)
      else:
          raise ValueError(
              "border_mode must be one of "
              "'nearest', 'mirror', 'wrap'"
          )
      x0, x1, y0, y1 = (T.cast(v, "int64") for v in (x0, x1, y0, y1))
  
      # The input is [num_batch, height, width, channels]. We do the lookup in
      # the flattened input, i.e [num_batch*height*width, channels]. We need
      # to offset all indices to match the flat version
      dim2 = width
      dim1 = width * height
      base = T.repeat(
          T.arange(num_batch, dtype="int64") * dim1,
          out_height * out_width,
      )
      base_y0 = base + y0 * dim2
      base_y1 = base + y1 * dim2
      idx_a = base_y0 + x0
      idx_b = base_y1 + x0
      idx_c = base_y0 + x1
      idx_d = base_y1 + x1
  
      # use indices to lookup pixels for all samples
      im_flat = im.reshape((-1, channels))
      Ia = im_flat[idx_a]
      Ib = im_flat[idx_b]
      Ic = im_flat[idx_c]
      Id = im_flat[idx_d]
  
      # calculate interpolated values
      wa = ((x1_f - x) * (y1_f - y)).dimshuffle(0, "x")
      wb = ((x1_f - x) * (y - y0_f)).dimshuffle(0, "x")
      wc = ((x - x0_f) * (y1_f - y)).dimshuffle(0, "x")
      wd = ((x - x0_f) * (y - y0_f)).dimshuffle(0, "x")
      output = T.sum([wa * Ia, wb * Ib, wc * Ic, wd * Id], axis=0)
      return output
  
imports: import theano
  import theano.tensor
  import numpy
  from ..None import init
  from ..None import nonlinearities
  from ..utils import as_tuple, floatX, int_types
  from ..random import get_rng
  from .base import Layer, MergeLayer
  from theano.sandbox.rng_mrg import MRG_RandomStreams
label_desc: Use image node_id 3 for calling a global function with example usage: _interpolate(im, x, y, out_height, out_width, border_mode) and returns: output