code: def wiener(im, mysize=None, noise=None):
      """
      Perform a Wiener filter on an N-dimensional array.
  
      Apply a Wiener filter to the N-dimensional array `im`.
  
      Parameters
      ----------
      im : ndarray
          An N-dimensional array.
      mysize : int or array_like, optional
          A scalar or an N-length list giving the size of the Wiener filter
          window in each dimension.  Elements of mysize should be odd.
          If mysize is a scalar, then this scalar is used as the size
          in each dimension.
      noise : float, optional
          The noise-power to use. If None, then noise is estimated as the
          average of the local variance of the input.
  
      Returns
      -------
      out : ndarray
          Wiener filtered result with the same shape as `im`.
  
      """
      im = cp.asarray(im)
      if mysize is None:
          mysize = [3] * im.ndim
      mysize = np.asarray(mysize)
      if mysize.shape == ():
          mysize = cp.repeat(mysize.item(), im.ndim)
          mysize = np.asarray(mysize)
  
      lprod = cp.prod(mysize, axis=0)
      lMean = correlate(im, cp.ones(mysize), "same")
      lVar = correlate(im**2, cp.ones(mysize), "same")
  
      lMean, lVar = _wiener_prep_kernel(lMean, lVar, lprod)
  
      # Estimate the noise power if needed.
      if noise is None:
          noise = cp.mean(cp.ravel(lVar), axis=0)
  
      return _wiener_post_kernel(im, lMean, lVar, noise)
  
imports: import cupy
  import numpy
  from cupyx.scipy import linalg
  from ..convolution.correlate import correlate
  from ..filter_design.filter_design_utils import _validate_sos
  from ..utils.arraytools import _axis_reverse, _axis_slice, _const_ext, _even_ext, _odd_ext
  from ..utils.helper_tools import _get_max_smem, _get_max_tpb
  from ._channelizer_cuda import _channelizer
  from ._sosfilt_cuda import _sosfilt
label_desc: Use image node_id 1 for calling a global function with example usage: wiener(im, mysize, noise) and returns: _wiener_post_kernel