code: def _reshape_nd(arr, ndim, dim):
      """Reshape a 1D array to have n dimensions, all singletons but one.
  
      Parameters
      ----------
      arr : array, shape (N,)
          Input array
      ndim : int
          Number of desired dimensions of reshaped array.
      dim : int
          Which dimension/axis will not be singleton-sized.
  
      Returns
      -------
      arr_reshaped : array, shape ([1, ...], N, [1,...])
          View of `arr` reshaped to the desired shape.
  
      Examples
      --------
      >>> rng = np.random.default_rng()
      >>> arr = rng.random(7)
      >>> _reshape_nd(arr, 2, 0).shape
      (7, 1)
      >>> _reshape_nd(arr, 3, 1).shape
      (1, 7, 1)
      >>> _reshape_nd(arr, 4, -1).shape
      (1, 1, 1, 7)
      """
      kernel_shape = _kernel_shape(ndim, dim)
      return np.reshape(arr, kernel_shape)
  
imports: import numpy
  from scipy import ndimage
  from scipy.ndimage import binary_erosion, convolve
  from .._shared.utils import _supported_float_type, check_nD
  from ..restoration.uft import laplacian
  from ..util.dtype import img_as_float
label_desc: Use image node_id 3 for calling a global function with example usage: _reshape_nd(arr, ndim, dim) and returns: np