code: def hilbert(x, N=None, axis=-1):
      """
      Compute the analytic signal, using the Hilbert transform.
  
      The transformation is done along the last axis by default.
  
      Parameters
      ----------
      x : ndarray
          Signal data.  Must be real.
      N : int, optional
          Number of Fourier components.  Default: ``x.shape[axis]``
      axis : int, optional
          Axis along which to do the transformation.  Default: -1.
  
      Returns
      -------
      xa : ndarray
          Analytic signal of `x`, of each 1-D array along `axis`
  
      Notes
      -----
      The analytic signal ``x_a(t)`` of signal ``x(t)`` is:
  
      .. math:: x_a = F^{-1}(F(x) 2U) = x + i y
  
      where `F` is the Fourier transform, `U` the unit step function,
      and `y` the Hilbert transform of `x`. [1]_
  
      In other words, the negative half of the frequency spectrum is zeroed
      out, turning the real-valued signal into a complex signal.  The Hilbert
      transformed signal can be obtained from ``np.imag(hilbert(x))``, and the
      original signal from ``np.real(hilbert(x))``.
  
      References
      ----------
      .. [1] Wikipedia, "Analytic signal".
             https://en.wikipedia.org/wiki/Analytic_signal
  
      See Also
      --------
      scipy.signal.hilbert
  
      """
      if cupy.iscomplexobj(x):
          raise ValueError("x must be real.")
      if N is None:
          N = x.shape[axis]
      if N <= 0:
          raise ValueError("N must be positive.")
  
      Xf = sp_fft.fft(x, N, axis=axis)
      h = cupy.zeros(N, dtype=Xf.dtype)
      if N % 2 == 0:
          h[0] = h[N // 2] = 1
          h[1 : N // 2] = 2
      else:
          h[0] = 1
          h[1 : (N + 1) // 2] = 2
  
      if x.ndim > 1:
          ind = [cupy.newaxis] * x.ndim
          ind[axis] = slice(None)
          h = h[tuple(ind)]
      x = sp_fft.ifft(Xf * h, axis=axis)
      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 29 for calling a global function with example usage: hilbert(x, N, axis) and returns: x