def forward(self, inputs):
    (x,) = inputs
    xp = cuda.get_array_module(x)
    (B, C, H, W, D) = x.shape
    u_1d = xp.linspace(0, (W - 1), num=self.out_W)
    v_1d = xp.linspace(0, (H - 1), num=self.out_H)
    t_1d = xp.linspace(0, (D - 1), num=self.out_D)
    grid = xp.meshgrid(u_1d, v_1d, t_1d)
    u = grid[0].ravel()
    v = grid[1].ravel()
    t = grid[2].ravel()
    u0 = xp.floor(u).astype(numpy.int32)
    u0 = u0.clip(0, (W - 2))
    u1 = (u0 + 1)
    v0 = xp.floor(v).astype(numpy.int32)
    v0 = v0.clip(0, (H - 2))
    v1 = (v0 + 1)
    t0 = xp.floor(t).astype(numpy.int32)
    t0 = t0.clip(0, (D - 2))
    t1 = (t0 + 1)
    w1 = (((u1 - u) * (v1 - v)) * (t1 - t))
    w2 = (((u - u0) * (v1 - v)) * (t1 - t))
    w3 = (((u1 - u) * (v - v0)) * (t1 - t))
    w4 = (((u - u0) * (v - v0)) * (t1 - t))
    w5 = (((u1 - u) * (v1 - v)) * (t - t0))
    w6 = (((u - u0) * (v1 - v)) * (t - t0))
    w7 = (((u1 - u) * (v - v0)) * (t - t0))
    w8 = (((u - u0) * (v - v0)) * (t - t0))
    w1 = w1.astype(x.dtype)
    w2 = w2.astype(x.dtype)
    w3 = w3.astype(x.dtype)
    w4 = w4.astype(x.dtype)
    w5 = w5.astype(x.dtype)
    w6 = w6.astype(x.dtype)
    w7 = w7.astype(x.dtype)
    w8 = w8.astype(x.dtype)
    y = ((((((((w1[None, None, :] * x[:, :, v0, u0, t0]) + (w2[None, None, :] * x[:, :, v0, u1, t0])) + (w3[None, None, :] * x[:, :, v1, u0, t0])) + (w4[None, None, :] * x[:, :, v1, u1, t0])) + (w5[None, None, :] * x[:, :, v0, u0, t1])) + (w6[None, None, :] * x[:, :, v0, u1, t1])) + (w7[None, None, :] * x[:, :, v1, u0, t1])) + (w8[None, None, :] * x[:, :, v1, u1, t1]))
    y = y.reshape(B, C, self.out_H, self.out_W, self.out_D)
    return (y,)
def forward(self, inputs):
    (x,) = inputs
    xp = cuda.get_array_module(x)
    (B, C, H, W, D) = x.shape
    u_1d = xp.linspace(0, (W - 1), num=self.out_W)
    v_1d = xp.linspace(0, (H - 1), num=self.out_H)
    t_1d = xp.linspace(0, (D - 1), num=self.out_D)
    grid = xp.meshgrid(u_1d, v_1d, t_1d)
    u = grid[0].ravel()
    v = grid[1].ravel()
    t = grid[2].ravel()
    u0 = xp.floor(u).astype(numpy.int32)
    u0 = u0.clip(0, (W - 2))
    u1 = (u0 + 1)
    v0 = xp.floor(v).astype(numpy.int32)
    v0 = v0.clip(0, (H - 2))
    v1 = (v0 + 1)
    t0 = xp.floor(t).astype(numpy.int32)
    t0 = t0.clip(0, (D - 2))
    t1 = (t0 + 1)
    w1 = (((u1 - u) * (v1 - v)) * (t1 - t))
    w2 = (((u - u0) * (v1 - v)) * (t1 - t))
    w3 = (((u1 - u) * (v - v0)) * (t1 - t))
    w4 = (((u - u0) * (v - v0)) * (t1 - t))
    w5 = (((u1 - u) * (v1 - v)) * (t - t0))
    w6 = (((u - u0) * (v1 - v)) * (t - t0))
    w7 = (((u1 - u) * (v - v0)) * (t - t0))
    w8 = (((u - u0) * (v - v0)) * (t - t0))
    w1 = w1.astype(x.dtype)
    w2 = w2.astype(x.dtype)
    w3 = w3.astype(x.dtype)
    w4 = w4.astype(x.dtype)
    w5 = w5.astype(x.dtype)
    w6 = w6.astype(x.dtype)
    w7 = w7.astype(x.dtype)
    w8 = w8.astype(x.dtype)
    y = ((((((((w1[None, None, :] * x[:, :, v0, u0, t0]) + (w2[None, None, :] * x[:, :, v0, u1, t0])) + (w3[None, None, :] * x[:, :, v1, u0, t0])) + (w4[None, None, :] * x[:, :, v1, u1, t0])) + (w5[None, None, :] * x[:, :, v0, u0, t1])) + (w6[None, None, :] * x[:, :, v0, u1, t1])) + (w7[None, None, :] * x[:, :, v1, u0, t1])) + (w8[None, None, :] * x[:, :, v1, u1, t1]))
    y = y.reshape(B, C, self.out_H, self.out_W, self.out_D)
    return (y,)