code: def score_linear(
      X,
      y,
      rules: List[str],
      penalty="l1",
      prediction_task="regression",
      max_rules=30,
      alpha=None,
      cv=True,
      random_state=None,
  ) -> Tuple[List[Rule], List[float], float]:
      if alpha is not None:
          final_alpha = alpha
          if max_rules is not None:
              warn(
                  "Ignoring max_rules parameter since alpha passed explicitly"
              )
  
      elif max_rules is not None:
          final_alpha = get_best_alpha_under_max_rules(
              X,
              y,
              rules,
              penalty=penalty,
              prediction_task=prediction_task,
              max_rules=max_rules,
              cv=cv,
              random_state=random_state,
          )
      else:
          raise ValueError("Invalid alpha and max_rules passed")
  
      if prediction_task == "regression":
          lin_model = Lasso(
              alpha=final_alpha,
              random_state=random_state,
              max_iter=2000,
          )
      else:
          lin_model = LogisticRegression(
              penalty=penalty,
              C=(1 / final_alpha),
              solver="liblinear",
              random_state=random_state,
              max_iter=200,
          )
  
      lin_model.fit(X, y)
  
      coef_ = lin_model.coef_.flatten()
      coefs = list(coef_[: coef_.shape[0] - len(rules)])
      support = np.sum(X[:, -len(rules) :], axis=0) / X.shape[0]
  
      nonzero_rules = []
      coef_zero_threshold = 1e-6 / np.mean(np.abs(y))
      for r, w, s in zip(rules, coef_[-len(rules) :], support):
          if abs(w) > coef_zero_threshold:
              nonzero_rules.append(Rule(r, args=[w], support=s))
              coefs.append(w)
  
      return nonzero_rules, coefs, lin_model.intercept_
  
file_path: imodels/imodels/util/score.py
imports: from typing import List, Tuple
  from warnings import warn
  import pandas
  import numpy
  from sklearn.utils import indices_to_mask
  from sklearn.linear_model import Lasso, LogisticRegression
  from sklearn.linear_model._coordinate_descent import _alpha_grid
  from sklearn.model_selection import cross_val_score
  from imodels.util.rule import Rule
label_desc: Use image node_id 3 for calling a global function with example usage: score_linear(X, y, rules, penalty, prediction_task, max_rules, alpha, cv, random_state) and returns: nonzero_rules,  coefs,  lin_model