code: def warp_by_grid_linear_3d(
      inp, grid, mode, padding_mode, align_corners, channel_last
  ):
      B, C, Di, Hi, Wi = inp.shape
      B, Do, Ho, Wo, _ = grid.shape
      out = np.zeros((B, C, Do, Ho, Wo))
      for b, c, d, h, w in product(
          range(B), range(C), range(Do), range(Ho), range(Wo)
      ):
          xf = unnormalize_grid(grid[b, d, h, w, 0], Wi, align_corners)
          yf = unnormalize_grid(grid[b, d, h, w, 1], Hi, align_corners)
          zf = unnormalize_grid(grid[b, d, h, w, 2], Di, align_corners)
          xf = get_src_findex_by_pad(
              xf, Wi, padding_mode, align_corners
          )
          yf = get_src_findex_by_pad(
              yf, Hi, padding_mode, align_corners
          )
          zf = get_src_findex_by_pad(
              zf, Di, padding_mode, align_corners
          )
          xi0 = np.floor(xf)
          yi0 = np.floor(yf)
          zi0 = np.floor(zf)
          xi0 = int(xi0)
          yi0 = int(yi0)
          zi0 = int(zi0)
          xi1 = xi0 + 1
          yi1 = yi0 + 1
          zi1 = zi0 + 1
          px0 = xf - xi0
          py0 = yf - yi0
          pz0 = zf - zi0
          px1 = 1.0 - px0
          py1 = 1.0 - py0
          pz1 = 1.0 - pz0
  
          v_z0y0x0 = get_pixel_value_3d(
              inp, b, c, zi0, yi0, xi0, Di, Hi, Wi
          )
          v_z0y0x1 = get_pixel_value_3d(
              inp, b, c, zi0, yi0, xi1, Di, Hi, Wi
          )
          v_z0y1x0 = get_pixel_value_3d(
              inp, b, c, zi0, yi1, xi0, Di, Hi, Wi
          )
          v_z0y1x1 = get_pixel_value_3d(
              inp, b, c, zi0, yi1, xi1, Di, Hi, Wi
          )
          v_z1y0x0 = get_pixel_value_3d(
              inp, b, c, zi1, yi0, xi0, Di, Hi, Wi
          )
          v_z1y0x1 = get_pixel_value_3d(
              inp, b, c, zi1, yi0, xi1, Di, Hi, Wi
          )
          v_z1y1x0 = get_pixel_value_3d(
              inp, b, c, zi1, yi1, xi0, Di, Hi, Wi
          )
          v_z1y1x1 = get_pixel_value_3d(
              inp, b, c, zi1, yi1, xi1, Di, Hi, Wi
          )
  
          val = (
              v_z0y0x0 * pz1 * py1 * px1
              + v_z0y0x1 * pz1 * py1 * px0
              + v_z0y1x0 * pz1 * py0 * px1
              + v_z0y1x1 * pz1 * py0 * px0
              + v_z1y0x0 * pz0 * py1 * px1
              + v_z1y0x1 * pz0 * py1 * px0
              + v_z1y1x0 * pz0 * py0 * px1
              + v_z1y1x1 * pz0 * py0 * px0
          )
          out[b, c, d, h, w] = val
      return out
  
imports: import pytest
  import numpy
  import nnabla
  import nnabla.functions
  from nbla_test_utils import list_context
  from refs import generate_transformation_2d, generate_transformation_3d, affine_grid_2d, affine_grid_3d, ChannelLastToFirstTranspose
  from itertools import product
label_desc: Use image node_id 10 for calling a global function with example usage: warp_by_grid_linear_3d(inp, grid, mode, padding_mode, align_corners, channel_last) and returns: out