code: def detrend(x, order=1, axis=-1):
      """Detrend the array x.
  
      Parameters
      ----------
      x : n-d array
          Signal to detrend.
      order : int
          Fit order. Currently must be '0' or '1'.
      axis : int
          Axis of the array to operate on.
  
      Returns
      -------
      y : array
          The x array detrended.
  
      Examples
      --------
      As in :func:`scipy.signal.detrend`::
  
          >>> randgen = np.random.RandomState(9)
          >>> npoints = int(1e3)
          >>> noise = randgen.randn(npoints)
          >>> x = 3 + 2*np.linspace(0, 1, npoints) + noise
          >>> bool((detrend(x) - noise).max() < 0.01)
          True
      """
      if axis > len(x.shape):
          raise ValueError("x does not have %d axes" % axis)
      if order == 0:
          fit = "constant"
      elif order == 1:
          fit = "linear"
      else:
          raise ValueError("order must be 0 or 1")
  
      y = signal.detrend(x, axis=axis, type=fit)
  
      return y
  
imports: from collections import Counter
  from copy import deepcopy
  from functools import partial
  from math import gcd
  import numpy
  from scipy import fft, signal
  from scipy.stats import f
  from ._fiff.pick import _picks_to_idx
  from ._ola import _COLA
  from .cuda import _fft_multiply_repeated, _fft_resample, _setup_cuda_fft_multiply_repeated, _setup_cuda_fft_resample, _smart_pad
  from .parallel import parallel_func
  from .utils import _check_option, _check_preload, _ensure_int, _pl, _validate_type, logger, sum_squared, verbose, warn
label_desc: Use image node_id 29 for calling a global function with example usage: detrend(x, order, axis) and returns: y