code: def adaptive_lasso_cv(
      x,
      y,
      initial_coef,
      regularization_strength=None,
      max_min_ratio=1e6,
  ):
      """Performs the adaptive lasso cross-validation.
  
       Algorithm is based on a transformation of `sklearn.linear_model.LassoCV()`.
       If initial_coef is not available, a lasso estimator is computed.
  
      Parameters
      ----------
      x : `numpy.array`
          The design matrix.
      y : `numpy.array`
          The response vector.
      initial_coef : `str` in ["ridge", "lasso", "old"] or `numpy.array`
          How to obtain the initial estimator. If a `str` is provided, the corresponding model is trained
          to obtain the initial estimator. If a `numpy.array` is provided, it is used as the initial
          estimator.
      regularization_strength : `float` in [0, 1] or `None`
          The regularization strength for change points. Greater values imply fewer change points.
          0 indicates all change points, and 1 indicates no change point.
          If `None`, cross-validation will be used to select tuning parameter,
          else the value will be used as the tuning parameters.
      max_min_ratio : `float`
          defines the min lambda by defining the ratio of lambda_max / lambda_min.
          `sklearn.linear_model.lasso_path` uses 1e3, but 1e6 seems better here.
  
      Returns
      -------
      intercept : `float`
          The estimated intercept.
      coef : `numpy.array`
          The estimated coefficients.
      """
      if regularization_strength is not None and (
          regularization_strength < 0 or regularization_strength > 1
      ):
          raise ValueError(
              "regularization_strength must be between 0.0 and 1.0."
          )
      if regularization_strength == 0:
          # regularization_strength == 0 implies linear regression
          model = LinearRegression().fit(x, y)
          return model.intercept_, model.coef_
      if regularization_strength == 1:
          # regularization_strength == 1 implies no change point selected
          # handle this case here separately for algorithm convergence and rounding concerns
          intercept = y.mean()
          coef = np.zeros(x.shape[1])
          return intercept, coef
      if type(initial_coef) == str:
          model = {
              "lasso": LassoCV(),
              "ols": LinearRegression(),
              "ridge": RidgeCV(),
          }[initial_coef]
          model.fit(x, y)
          initial_coef = model.coef_
      else:
          assert x.shape[1] == len(initial_coef), (
              "the number of columns in x should equal to the length of weights"
              f"but got {x.shape[1]} and {len(initial_coef)}."
          )
      weights = np.where(
          initial_coef != 0, 1 / abs(initial_coef), 1e16
      )  # 1e16 is big enough for most cases.
      x_t = x / weights
      if regularization_strength is None:
          model = LassoCV().fit(x_t, y)
      else:
          # finds the minimum lambda that corresponds to no selection, formula derived from KKT condition.
          # this is the max lambda we need to consider
          max_lam = (
              max(abs(np.matmul(x_t.T, y - y.mean()))) / x.shape[0]
          )
          # the lambda we choose is ``regularization_strength``th log-percentile of [lambda_min, lambda_max]
          lam = 10 ** (
              np.log10(max_lam / max_min_ratio)
              + np.log10(max_min_ratio) * regularization_strength
          )
          model = Lasso(alpha=lam).fit(x_t, y)
      intercept = model.intercept_
      coef = model.coef_ / weights
      return intercept, coef
  
imports: import warnings
  from datetime import timedelta
  import numpy
  import pandas
  import plotly.graph_objects
  from pandas.plotting import register_matplotlib_converters
  from pandas.tseries.frequencies import to_offset
  from sklearn.linear_model import Lasso
  from sklearn.linear_model import LassoCV
  from sklearn.linear_model import LinearRegression
  from sklearn.linear_model import RidgeCV
  from greykite.common.constants import CHANGEPOINT_COL_PREFIX
  from greykite.common.constants import TimeFeaturesEnum
  from greykite.common.features.timeseries_features import add_time_features_df
  from greykite.common.features.timeseries_features import build_time_features_df
  from greykite.common.features.timeseries_features import fourier_series_multi_fcn
  from greykite.common.features.timeseries_features import get_changepoint_dates_from_changepoints_dict
  from greykite.common.features.timeseries_features import get_changepoint_features
  from greykite.common.features.timeseries_features import get_changepoint_features_and_values_from_config
  from greykite.common.features.timeseries_features import get_default_origin_for_time_vars
  from greykite.common.python_utils import get_pattern_cols
  from greykite.common.python_utils import unique_elements_in_list
label_desc: Use image node_id 7 for calling a global function with example usage: adaptive_lasso_cv(x, y, initial_coef, regularization_strength, max_min_ratio) and returns: intercept,  coef, model,  model, intercept,  coef