code: def remove_trend(
      ts: TimeSeries,
      model: ModelMode = ModelMode.MULTIPLICATIVE,
      method: str = "naive",
      **kwargs,
  ) -> TimeSeries:
      """
      Adjusts the TimeSeries `ts` for a trend using the `model` decomposition.
  
      Parameters
      ----------
      ts
          The TimeSeries to adjust.
      model
          The type of decomposition to use.
          Must be a ``from darts.utils.utils import ModelMode`` Enum member.
          Either ``MULTIPLICATIVE`` or ``ADDITIVE``.
          Defaults ``ModelMode.MULTIPLICATIVE``.
      method
          The method to be used to decompose the series.
          - "naive" : Seasonal decomposition using moving averages [1]_.
          - "STL" : Season-Trend decomposition using LOESS [2]_. Only compatible with ``ADDITIVE`` model type.
          Defaults to "naive"
      kwargs
          Other keyword arguments are passed down to the decomposition method.
  
      Returns
      -------
      TimeSeries
          A new TimeSeries instance that corresponds to the trend-adjusted 'ts'.
      """
  
      ts._assert_univariate()
  
      raise_if(
          model not in [SeasonalityMode.ADDITIVE, ModelMode.ADDITIVE]
          and method == "STL",
          f"Only ADDITIVE seasonality is compatible with the STL method. Current model is {model}.",
          logger,
      )
      trend, _ = extract_trend_and_seasonality(
          ts, model=model, method=method, **kwargs
      )
      new_ts = remove_from_series(ts, trend, model)
      return new_ts
  
imports: import math
  from typing import List, Optional, Sequence, Tuple, Union
  import matplotlib.pyplot
  import numpy
  from scipy.signal import argrelmax
  from scipy.stats import norm
  from statsmodels.tsa.seasonal import MSTL, STL, seasonal_decompose
  from statsmodels.tsa.stattools import acf, adfuller, grangercausalitytests, kpss, pacf
  from darts import TimeSeries
  from darts.logging import get_logger, raise_if, raise_if_not, raise_log
  from .missing_values import fill_missing_values
  from .utils import ModelMode, SeasonalityMode
label_desc: Use image node_id 6 for calling a global function with example usage: remove_trend(ts, model, method) and returns: new_ts