code: def hilbert2(x, N=None):
      """
      Compute the '2-D' analytic signal of `x`
  
      Parameters
      ----------
      x : ndarray
          2-D signal data.
      N : int or tuple of two ints, optional
          Number of Fourier components. Default is ``x.shape``
  
      Returns
      -------
      xa : ndarray
          Analytic signal of `x` taken along axes (0,1).
  
      See Also
      --------
      scipy.signal.hilbert2
  
      """
      if x.ndim < 2:
          x = cupy.atleast_2d(x)
      if x.ndim > 2:
          raise ValueError("x must be 2-D.")
      if cupy.iscomplexobj(x):
          raise ValueError("x must be real.")
      if N is None:
          N = x.shape
      elif isinstance(N, int):
          if N <= 0:
              raise ValueError("N must be positive.")
          N = (N, N)
      elif len(N) != 2 or (N[0] <= 0 or N[1] <= 0):
          raise ValueError(
              "When given as a tuple, N must hold exactly "
              "two positive integers"
          )
  
      Xf = sp_fft.fft2(x, N, axes=(0, 1))
      h1 = cupy.zeros(N[0], dtype=Xf.dtype)
      h2 = cupy.zeros(N[1], dtype=Xf.dtype)
      for h in (h1, h1):
          N1 = h.shape[0]
          if N1 % 2 == 0:
              h[0] = h[N1 // 2] = 1
              h[1 : N1 // 2] = 2
          else:
              h[0] = 1
              h[1 : (N1 + 1) // 2] = 2
  
      h = h1[:, cupy.newaxis] * h2[cupy.newaxis, :]
      k = x.ndim
      while k > 2:
          h = h[:, cupy.newaxis]
          k -= 1
      x = sp_fft.ifft2(Xf * h, axes=(0, 1))
      return x
  
imports: import warnings
  import cupy
  from cupy._core import internal
  from cupy.linalg import lstsq
  import cupyx.scipy.fft
  from cupyx.scipy.ndimage import _util
  from cupyx.scipy.ndimage import _filters
  from cupyx.scipy.signal import _signaltools_core
  from cupyx.scipy.signal._arraytools import const_ext, even_ext, odd_ext, axis_reverse, axis_slice, axis_assign
  from cupyx.scipy.signal._iir_utils import apply_iir, apply_iir_sos, compute_correction_factors, compute_correction_factors_sos
label_desc: Use image node_id 30 for calling a global function with example usage: hilbert2(x, N) and returns: x