code: def cast_array(arr, dtype):
      """
      arr : array
        Input array
  
      dtype : dtype
        Desired dtype
      """
      if dtype.kind in "iu":
          mn, mx = shared_range(arr.dtype, dtype)
          return np.clip(np.round(arr), mn, mx).astype(dtype)
      else:
          return arr.astype(dtype)
  
file_path: nipy/nipy/algorithms/registration/resample.py
imports: import numpy
  from nibabel.casting import shared_range
  from scipy.ndimage import affine_transform, map_coordinates
  from ...core.image.image_spaces import as_xyz_image, make_xyz_image, xyz_affine
  from ._registration import _cspline_resample3d, _cspline_sample3d, _cspline_transform
  from .affine import Affine, inverse_affine
label_desc: Use image node_id 1 for calling a global function with example usage: cast_array(arr, dtype) and returns: np, arr