code: def add_model_params_lm(info_dict):
      """Adds model parameter information to ``info_dict`` for linear models.
  
      Only model-related information will be added in this function.
      A series of these functions are used in a flow to get all information needed
      in linear model summary. The flow is
      `~greykite.algo.common.model_summary_utils.create_info_dict_lm`,
      `~greykite.algo.common.model_summary_utils.add_model_params_lm`,
      `~greykite.algo.common.model_summary_utils.add_model_df_lm`,
      `~greykite.algo.common.model_summary_utils.add_model_ss_lm`,
      `~greykite.algo.common.model_summary_utils.add_beta_var_lm`,
      `~greykite.algo.common.model_summary_utils.add_model_coef_df_lm`,
      `cadd_model_significance_lm`.
      For flow implementation, see
      `~greykite.algo.common.model_summary_utils.get_info_dict_lm`.
  
      Parameters
      ----------
      info_dict : `dict`
          The information dictionary returned by
          `~greykite.algo.common.model_summary_utils.create_info_dict_lm`.
  
      Returns
      -------
      info_dict : `dict`
          The information dictionary with the following keys added:
  
              "model" : `str`
                  The model name.
              "weights" : `numpy.array`, optional
                  The weight matrix.
              "family" : `str`, optional
                  The distribution family in generalized linear model.
              "link_function" : `str`, optional
                  The link function used in generalized linear model.
              "alpha" : `float`, optional
                  The regularization parameter in regularized methods.
              "l1_ratio" : `float`, optional
                  The l1 norm ratio in Elastic Net methods.
      """
      fit_algorithm = info_dict["fit_algorithm"]
      ml_model = info_dict["ml_model"]
      n_sample = info_dict["n_sample"]
      # Dictionary for model parameters
      valid_linear_fit_algorithms = [
          "linear",
          "statsmodels_ols",
          "statsmodels_wls",
          "statsmodels_gls",
          "statsmodels_glm",
          "ridge",
          "lasso",
          "lars",
          "lasso_lars",
          "sgd",
          "elastic_net",
      ]
      if fit_algorithm in valid_linear_fit_algorithms:
          # Adds special parameters
          if fit_algorithm in ["linear", "statsmodels_ols"]:
              info_dict["model"] = "Ordinary least squares"
          elif fit_algorithm == "statsmodels_wls":
              info_dict["model"] = "Weighted least squares"
              info_dict["weights"] = ml_model.model.weights
          elif fit_algorithm == "statsmodels_gls":
              info_dict["model"] = "Generalized least squares"
              info_dict["weights"] = ml_model.model.sigma
          elif fit_algorithm == "statsmodels_glm":
              info_dict["model"] = "Generalized linear model"
              info_dict[
                  "family"
              ] = ml_model.model.family.__class__.__name__
              info_dict[
                  "link_function"
              ] = ml_model.model.family.link.__class__.__name__
          elif fit_algorithm in [
              "ridge",
              "lasso",
              "lars",
              "lasso_lars",
          ]:
              info_dict["model"] = (
                  fit_algorithm.capitalize() + " regression"
              )
              info_dict["alpha"] = ml_model.alpha_
          elif fit_algorithm == "elastic_net":
              info_dict["model"] = "Elastic Net regression"
              info_dict["alpha"] = ml_model.alpha_
              info_dict["l1_ratio"] = ml_model.l1_ratio_
          elif fit_algorithm == "sgd":
              info_dict["model"] = "Elastic Net regression via SGD"
              info_dict[
                  "alpha"
              ] = (
                  ml_model.alpha
              )  # does not have underscore, because this is not cv
              if info_dict["ml_model"].penalty == "l1":
                  info_dict["l1_ratio"] = 1.0
              elif info_dict["ml_model"].penalty == "l2":
                  info_dict["l1_ratio"] = 0.0
              else:
                  info_dict["l1_ratio"] = ml_model.l1_ratio
  
          # Processes parameters
          if "weights" in info_dict:
              if info_dict["weights"] is None:
                  weights = np.eye(info_dict["n_sample"])
              else:
                  weights = np.array(info_dict["weights"])
                  if (
                      weights.shape == ()
                  ):  # checks if weights is a scalar
                      weights = np.diag(np.repeat(weights, n_sample))
                  elif weights.shape == (
                      n_sample,
                  ) or weights.shape == (
                      n_sample,
                      1,
                  ):  # checks if weights is a vector
                      weights = np.diag(weights.ravel())
                  elif weights.shape == (n_sample, n_sample):
                      weights = weights
                  else:
                      raise ValueError(
                          "The shape of weights does not match the design matrix. "
                          f"The design matrix has length {n_sample}. "
                          f"The weights has shape {weights.shape}."
                      )
              info_dict["weights"] = weights
      else:
          raise ValueError(
              f"{fit_algorithm} is not a valid algorithm, it must be in "
              f"{valid_linear_fit_algorithms}."
          )
      return info_dict
  
imports: import numpy
  import pandas
  import statsmodels
  import statsmodels.api
  from scipy.stats import f
  from scipy.stats import norm
  from scipy.stats import t
  from sklearn.base import clone
  from sklearn.linear_model import Ridge
  from sklearn.model_selection import train_test_split
  from greykite.algo.common.col_name_utils import INTERCEPT
  from greykite.algo.common.col_name_utils import simplify_pred_cols
label_desc: Use image node_id 4 for calling a global function with example usage: add_model_params_lm(info_dict) and returns: info_dict