docstr: adding static covariates to lagged data logic is tested in
  `darts.tests.utils.data.tabularization.test_add_static_covariates`
code: def test_optional_static_covariates(self, model_cls):
      """adding static covariates to lagged data logic is tested in
      `darts.tests.utils.data.tabularization.test_add_static_covariates`
      """
      series = (
          tg.linear_timeseries(length=6)
          .with_static_covariates(pd.DataFrame({"a": [1]}))
          .astype(np.float32)
      )
      # training model with static covs and predicting without will raise an error
      model = model_cls(lags=4, use_static_covariates=True)
      model.fit(series)
      assert model.uses_static_covariates
      assert (
          model._static_covariates_shape
          == series.static_covariates.shape
      )
      with pytest.raises(ValueError):
          model.predict(n=2, series=series.with_static_covariates(None))
  
      # with `use_static_covariates=True`, all series must have static covs
      model = model_cls(lags=4, use_static_covariates=True)
      with pytest.raises(ValueError):
          model.fit([series, series.with_static_covariates(None)])
  
      # with `use_static_covariates=True`, all static covs must have same shape
      model = model_cls(lags=4, use_static_covariates=True)
      with pytest.raises(ValueError):
          model.fit(
              [
                  series,
                  series.with_static_covariates(
                      pd.DataFrame({"a": [1], "b": [2]})
                  ),
              ]
          )
  
      # with `use_static_covariates=False`, static covariates are ignored and prediction works
      model = model_cls(lags=4, use_static_covariates=False)
      model.fit(series)
      assert not model.uses_static_covariates
      assert model._static_covariates_shape is None
      preds = model.predict(
          n=2, series=series.with_static_covariates(None)
      )
      assert preds.static_covariates is None
  
      # with `use_static_covariates=False`, static covariates are ignored and prediction works
      model = model_cls(lags=4, use_static_covariates=False)
      model.fit(series.with_static_covariates(None))
      assert not model.uses_static_covariates
      assert model._static_covariates_shape is None
      preds = model.predict(n=2, series=series)
      np.testing.assert_almost_equal(
          preds.static_covariates.values,
          series.static_covariates.values,
      )
  
      # with `use_static_covariates=True`, static covariates are included
      model = model_cls(lags=4, use_static_covariates=True)
      model.fit([series, series])
      assert model.uses_static_covariates
      assert (
          model._static_covariates_shape
          == series.static_covariates.shape
      )
      preds = model.predict(n=2, series=[series, series])
      for pred in preds:
          np.testing.assert_almost_equal(
              pred.static_covariates.values,
              series.static_covariates.values,
          )
  
imports: import copy
  import functools
  import itertools
  import math
  from unittest.mock import patch
  import numpy
  import pandas
  import pytest
  from sklearn.ensemble import HistGradientBoostingRegressor, RandomForestRegressor
  from sklearn.linear_model import LinearRegression
  import darts
  from darts import TimeSeries
  from darts.dataprocessing.encoders import FutureCyclicEncoder, PastDatetimeAttributeEncoder
  from darts.logging import get_logger
  from darts.metrics import mae, rmse
  from darts.models import CatBoostModel, LightGBMModel, LinearRegressionModel, NotImportedModule, RandomForest, RegressionModel, XGBModel
  from darts.utils import timeseries_generation
  from darts.utils.multioutput import MultiOutputRegressor
label_desc: Use image node_id 5 for calling the TestRegressionModels obj's underlying member method code with example usage: obj.test_optional_static_covariates(model_cls) without return types