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 : array_like
          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 ``cp.imag(hilbert(x))``, and the
      original signal from ``cp.real(hilbert(x))``.
  
      Examples
      ---------
      In this example we use the Hilbert transform to determine the amplitude
      envelope and instantaneous frequency of an amplitude-modulated signal.
  
      >>> import cupy as cp
      >>> import matplotlib.pyplot as plt
      >>> from cusignal import hilbert, chirp
  
      >>> duration = 1.0
      >>> fs = 400.0
      >>> samples = int(fs*duration)
      >>> t = cp.arange(samples) / fs
  
      We create a chirp of which the frequency increases from 20 Hz to 100 Hz and
      apply an amplitude modulation.
  
      >>> signal = chirp(t, 20.0, t[-1], 100.0)
      >>> signal *= (1.0 + 0.5 * cp.sin(2.0*cp.pi*3.0*t) )
  
      The amplitude envelope is given by magnitude of the analytic signal. The
      instantaneous frequency can be obtained by differentiating the
      instantaneous phase in respect to time. The instantaneous phase corresponds
      to the phase angle of the analytic signal.
  
      >>> analytic_signal = hilbert(signal)
      >>> amplitude_envelope = cp.abs(analytic_signal)
      >>> instantaneous_phase = cp.unwrap(cp.angle(analytic_signal))
      >>> instantaneous_frequency = (cp.diff(instantaneous_phase) /
      ...                            (2.0*cp.pi) * fs)
  
      >>> fig = plt.figure()
      >>> ax0 = fig.add_subplot(211)
      >>> ax0.plot(cp.asnumpy(t), cp.asnumpy(signal), label='signal')
      >>> ax0.plot(cp.asnumpy(t), cp.asnumpy(amplitude_envelope), \
          label='envelope')
      >>> ax0.set_xlabel("time in seconds")
      >>> ax0.legend()
      >>> ax1 = fig.add_subplot(212)
      >>> ax1.plot(t[1:], instantaneous_frequency)
      >>> ax1.set_xlabel("time in seconds")
      >>> ax1.set_ylim(0.0, 120.0)
  
      References
      ----------
      .. [1] Wikipedia, "Analytic signal".
             https://en.wikipedia.org/wiki/Analytic_signal
      .. [2] Leon Cohen, "Time-Frequency Analysis", 1995. Chapter 2.
      .. [3] Alan V. Oppenheim, Ronald W. Schafer. Discrete-Time Signal
             Processing, Third Edition, 2009. Chapter 12.
             ISBN 13: 978-1292-02572-8
  
      """
      x = cp.asarray(x)
      if cp.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 = cp.fft.fft(x, N, axis=axis)
  
      h = cp.empty((N,), dtype=x.dtype)
      _hilbert_kernel(h)
  
      if x.ndim > 1:
          ind = [cp.newaxis] * x.ndim
          ind[axis] = slice(None)
          h = h[tuple(ind)]
      x = cp.fft.ifft(Xf * h, axis=axis)
      return x
  
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 10 for calling a global function with example usage: hilbert(x, N, axis) and returns: x