code: def detrend(x, key=None):
      if key is None or key == "constant":
          return detrend_mean(x)
      elif key == "linear":
          return detrend_linear(x)
  
imports: import numpy
  from numpy.testing import assert_array_almost_equal
  import matplotlib.pyplot
  from statsmodels import regression
  from statsmodels.tsa.arima_process import arma_generate_sample, arma_impulse_response
  from statsmodels.tsa.arima_process import arma_acovf, arma_acf
  from statsmodels.tsa.arima.model import ARIMA
  from statsmodels.tsa.stattools import acf, acovf
  from statsmodels.graphics.tsaplots import plot_acf
label_desc: Use image node_id 1 for calling a global function with example usage: detrend(x, key) and returns: detrend_mean, detrend_linear