code: def ref_linear_interpolate_3d(
      x, output_size, align_corners, half_pixel
  ):
      oshape = output_size  # output-depth, output-height, output-width
      ishape = x.shape[-3:]  # input-depth, input-height, input-width
      xx = x.reshape(-1, *ishape)
      ib = np.arange(xx.shape[0])  # batch index
  
      scale = (
          compute_scale(ishape[0], oshape[0], align_corners),  # z
          compute_scale(ishape[1], oshape[1], align_corners),  # y
          compute_scale(ishape[2], oshape[2], align_corners),
      )  # x
  
      # Real input indices as floats
      index = (
          get_source_index(scale[0], np.arange(oshape[0]), half_pixel),
          get_source_index(scale[1], np.arange(oshape[1]), half_pixel),
          get_source_index(scale[2], np.arange(oshape[2]), half_pixel),
      )
  
      # Nearest input indices per axis
      index_1 = (
          index[0].astype(np.int32),
          index[1].astype(np.int32),
          index[2].astype(np.int32),
      )
      index_2 = (
          np.minimum(index_1[0] + 1, ishape[0] - 1),
          np.minimum(index_1[1] + 1, ishape[1] - 1),
          np.minimum(index_1[2] + 1, ishape[2] - 1),
      )
  
      # Unit distance to left and right
      dist_1 = (
          (index[0] - index_1[0]).reshape(1, -1, 1, 1),  # z
          (index[1] - index_1[1]).reshape(1, 1, -1, 1),  # y
          (index[2] - index_1[2]).reshape(1, 1, 1, -1),
      )  # x
      dist_2 = (1.0 - dist_1[0], 1.0 - dist_1[1], 1.0 - dist_1[2])
  
      val0 = (
          dist_2[2] * xx[np.ix_(ib, index_1[0], index_1[1], index_1[2])]
      )
      val1 = (
          dist_1[2] * xx[np.ix_(ib, index_1[0], index_1[1], index_2[2])]
      )
      val2 = (
          dist_2[2] * xx[np.ix_(ib, index_1[0], index_2[1], index_1[2])]
      )
      val3 = (
          dist_1[2] * xx[np.ix_(ib, index_1[0], index_2[1], index_2[2])]
      )
      val4 = (
          dist_2[2] * xx[np.ix_(ib, index_2[0], index_1[1], index_1[2])]
      )
      val5 = (
          dist_1[2] * xx[np.ix_(ib, index_2[0], index_1[1], index_2[2])]
      )
      val6 = (
          dist_2[2] * xx[np.ix_(ib, index_2[0], index_2[1], index_1[2])]
      )
      val7 = (
          dist_1[2] * xx[np.ix_(ib, index_2[0], index_2[1], index_2[2])]
      )
  
      val8 = (dist_2[1] * (val0 + val1)) + (dist_1[1] * (val2 + val3))
      val9 = (dist_2[1] * (val4 + val5)) + (dist_1[1] * (val6 + val7))
  
      yy = dist_2[0] * val8 + dist_1[0] * val9
  
      return yy.reshape(x.shape[: -len(oshape)] + oshape)
  
imports: from __future__ import division
  import pytest
  import numpy
  import nnabla.functions
  import refs
  from nbla_test_utils import list_context
label_desc: Use image node_id 8 for calling a global function with example usage: ref_linear_interpolate_3d(x, output_size, align_corners, half_pixel) and returns: yy