code: def test_regularization_lagged_regressor():
      """
      Test case for  regularization feature of lagged regressors. Utlizes a
      synthetic dataset with 4 noise-based lagged regressors (a, b, c, d).
      The first and last lagged regressors (a, d) are expected to have a weight
      close to 1. The middle lagged regressors (b, c) meanwhile are expected to
      have a weight close to 0, due to the regularization. All other model
      components are turned off to avoid side effects.
      """
      log.info("testing: regularization lagged regressors")
      df, lagged_regressors = generate_lagged_regressor_dataset(
          periods=100
      )
      df, _, _ = df_utils.check_dataframe(df, check_y=False)
  
      m = NeuralProphet(
          epochs=30,
          batch_size=8,
          learning_rate=0.1,
          yearly_seasonality=False,
          weekly_seasonality=False,
          daily_seasonality=False,
          growth="off",
          normalize="off",
      )
      m = m.add_lagged_regressor(
          n_lags=3,
          names=[
              lagged_regressor
              for lagged_regressor, _ in lagged_regressors
          ],
          regularization=0.1,
      )
      m.fit(df, freq="D")
  
      lagged_regressors_config = dict(lagged_regressors)
  
      weights = m.model.get_covar_weights()
      for name in m.config_lagged_regressors.keys():
          weight_average = np.average(weights[name].detach().numpy())
  
          lagged_regressor_weight = lagged_regressors_config[name]
  
          if lagged_regressor_weight > 0.9:
              assert weight_average > 0.5
          else:
              assert (
                  weight_average < 0.35
              )  # Note: this should be < 0.1, but due to fitting issues, relaxed temporarily.
  
          log.info(
              "Lagged regressor: %s, average weight: %f, expected weight: %f",
              name,
              weight_average,
              lagged_regressors_config[name],
          )
  
file_path: neural_prophet/tests/test_regularization.py
imports: import logging
  import random
  import numpy
  import pandas
  import pytest
  import torch
  from neuralprophet import NeuralProphet, df_utils
  from neuralprophet.utils import reg_func_abs
  from tests.utils.dataset_generators import generate_event_dataset, generate_holiday_dataset, generate_lagged_regressor_dataset
label_desc: Use image node_id 4 for calling a global function with example usage: test_regularization_lagged_regressor() without return types