code: def test_weighted_ElasticNet(sparse_X):
      n_samples, n_features = 30, 50
      X, y = build_dataset(n_samples, n_features, sparse_X)
  
      np.random.seed(0)
      weights = abs(np.random.randn(n_features))
      l1_ratio = 0.7
  
      params = {"max_iter": 10000, "tol": 1e-14, "fit_intercept": False}
  
      alpha_max = norm(X.T @ y / weights, ord=np.inf) / n_samples
      alpha = alpha_max / 100.0
  
      reg_enet = ElasticNet(
          alpha=alpha, l1_ratio=l1_ratio, **params
      ).fit(X, y)
  
      lmbda = alpha * l1_ratio * n_samples / (n_samples + n_features)
      mu = alpha * (1 - l1_ratio)
      X_tilde = np.vstack(
          (X, np.sqrt(n_samples * mu) * np.eye(n_features))
      )
      y_tilde = np.hstack((y, np.zeros(n_features)))
  
      reg_lasso = Lasso(alpha=lmbda, **params)
      reg_lasso.fit(X_tilde, y_tilde)
  
      assert_allclose(
          reg_enet.coef_, reg_lasso.coef_, rtol=1e-4, atol=1e-3
      )
  
file_path: celer/celer/tests/test_enet.py
imports: from itertools import product
  import pytest
  import numpy
  from numpy.linalg import norm
  from numpy.testing import assert_allclose, assert_array_less, assert_equal
  from sklearn.linear_model import enet_path, ElasticNet, ElasticNetCV
  from celer import Lasso, ElasticNet, celer_path, ElasticNetCV
  from celer.utils.testing import build_dataset
label_desc: Use image node_id 5 for calling a global function with example usage: test_weighted_ElasticNet(sparse_X) without return types