code: def resize_3d(img, size, order=1):
      r"""Resize the input numpy ndarray to the given size.
      Args:
          img (numpy ndarray): Image to be resized.
          size
          order (int, optional): Desired order of scipy.zoom . Default is 1
      Returns:
          Numpy Array
      """
      if not _is_numpy_image(img):
          raise TypeError(
              "img should be numpy image. Got {}".format(type(img))
          )
      if not (
          isinstance(size, int)
          or (
              isinstance(size, collections.abc.Iterable)
              and len(size) == 3
          )
      ):
          raise TypeError("Got inappropriate size arg: {}".format(size))
      d, h, w = img.shape[0], img.shape[1], img.shape[2]
  
      if isinstance(size, int):
          if min(d, h, w) == size:
              return img
          ow = int(size * w / min(d, h, w))
          oh = int(size * h / min(d, h, w))
          od = int(size * d / min(d, h, w))
      else:
          ow, oh, od = size[2], size[1], size[0]
  
      if img.ndim == 3:
          resize_factor = np.array([od, oh, ow]) / img.shape
          output = scipy.ndimage.zoom(
              img, resize_factor, mode="nearest", order=order
          )
      elif img.ndim == 4:
          resize_factor = (
              np.array([od, oh, ow, img.shape[3]]) / img.shape
          )
          output = scipy.ndimage.zoom(
              img, resize_factor, mode="nearest", order=order
          )
      return output
  
imports: from typing import List, Tuple, Union, Callable
  import collections
  import numbers
  import random
  import numpy
  import scipy
  import scipy.ndimage
  import SimpleITK
  from scipy.ndimage.filters import gaussian_filter, gaussian_gradient_magnitude
  from skimage.transform import resize
label_desc: Use image node_id 1 for calling a global function with example usage: resize_3d(img, size, order) and returns: output, img