code: def ref_nearest_interpolate_3d(
      x, output_size, align_corners, half_pixel, half_pixel_for_nn
  ):
      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_for_nn(
              ishape[0], oshape[0], align_corners, half_pixel_for_nn
          ),  # z
          compute_scale_for_nn(
              ishape[1], oshape[1], align_corners, half_pixel_for_nn
          ),  # y
          compute_scale_for_nn(
              ishape[2], oshape[2], align_corners, half_pixel_for_nn
          ),
      )  # x
  
      # Real input indices as floats
      index = (
          get_source_index_for_nn(
              scale[0],
              np.arange(oshape[0]),
              half_pixel,
              half_pixel_for_nn,
          ),
          get_source_index_for_nn(
              scale[1],
              np.arange(oshape[1]),
              half_pixel,
              half_pixel_for_nn,
          ),
          get_source_index_for_nn(
              scale[2],
              np.arange(oshape[2]),
              half_pixel,
              half_pixel_for_nn,
          ),
      )
  
      # 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], ishape[0] - 1),
          np.minimum(index_1[1], ishape[1] - 1),
          np.minimum(index_1[2], ishape[2] - 1),
      )
  
      # Nearest input
      yy = xx[np.ix_(ib, index_2[0], index_2[1], index_2[2])]
  
      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 11 for calling a global function with example usage: ref_nearest_interpolate_3d(x, output_size, align_corners, half_pixel, half_pixel_for_nn) and returns: yy