code: def l1_quantile_regression(
      x: np.array,
      y: np.array,
      q: float,
      alpha: float,
      sample_weight: Optional[np.array] = None,
      feature_weight: Optional[np.array] = None,
      include_intercept: bool = True,
  ) -> Dict[str, any]:
      """Implements the quantile regression with penalty terms.
      Supports sample weight and feature weights in penalty.
  
      This is solved with linear programming formulation:
  
          min c^Tx s.t. ax<=b
  
      where x is [beta+, beta-, alpha+, alpha-, (y-alpha-X beta)+, (y-alpha-X beta)-].
      Please make sure the design matrix is normalized.
  
      Parameters
      ----------
      x : `numpy.array`
          The design matrix.
      y : `numpy.array`
          The response vector.
      q : `float` between 0.0 and 1.0
          The quantile of the response to model.
      alpha : `float`
          The regularization parameter.
      sample_weight : `numpy.array` or None, default None
          The sample weight in the loss function.
      feature_weight : `numpy.array` or None, default None
          The feature weight in the penalty term.
          This parameter enables adaptive L1 norm regularization.
      include_intercept : `bool`, default True
          Whether to include intercept.
          If True, will fit an intercept separately and drop any degenerate columns.
          False is not recommended because intercept is very useful in distinguishing the quantiles
          (it shifts the predictions up and down).
  
      Returns
      -------
      coefs : `dict` [`str`, any]
          The coefficients dictionary with the following elements:
              intercept : `float`
                  The intercept.
              beta : `numpy.array`
                  The estimated coefficients.
  
      """
      n, p = x.shape
      if sample_weight is None:
          sample_weight = np.ones(n)
      if feature_weight is None:
          feature_weight = np.ones(p)
      # Linear coefficients.
      c = [alpha * feature_weight, alpha * feature_weight]
      if include_intercept:
          c += [np.zeros(2)]
      c += [q * sample_weight, (1 - q) * sample_weight]
      c = np.concatenate(c, axis=0)
      # Variable.
      var_size = 2 * p + 2 * n + 2 * include_intercept
      var = cp.Variable(var_size)
      # Equality constraint coefficients.
      x_vec = [x, -x]
      if include_intercept:
          x_vec += [np.ones([n, 1]), -np.ones([n, 1])]
      x_vec += [np.eye(n), -np.eye(n)]
      x_vec = np.concatenate(x_vec, axis=1)
      # The problem.
      prob = cp.Problem(
          cp.Minimize(c.T @ var), [var >= 0, x_vec @ var == y]
      )
      prob.solve()
  
      # Gets the results.
      if include_intercept:
          intercept = var.value[2 * p] - var.value[2 * p + 1]
      else:
          intercept = 0
      coef = var.value[:p] - var.value[p : 2 * p]
      return {"intercept": intercept, "coef": coef}
  
imports: from __future__ import annotations
  from typing import Dict
  from typing import Optional
  import cvxpy
  import numpy
  import pandas
  import scipy
  from sklearn.base import BaseEstimator
  from sklearn.base import RegressorMixin
  from greykite.algo.common.partial_regularize_regression import constant_col_finder
  from greykite.common.logging import LoggingLevelEnum
  from greykite.common.logging import log_message
label_desc: Use image node_id 2 for calling a global function with example usage: l1_quantile_regression(x, y, q, alpha, sample_weight, feature_weight, include_intercept) and returns: dict