docstr: Function that fit the model. Deriving classes can override this method for adding additional parameters (e.g.,
  adding validation data), keeping the sanity checks on series performed by fit().
docstr_tok: ["Function","that","fit","the","model",".","Deriving","classes","can","override","this","method","for","adding","additional","parameters","(","e.g.",",","adding","validation","data",")",",","keeping","the","sanity","checks","on","series","performed","by","fit","(",")","."]
code: def _fit_model(
      self,
      target_series: Sequence[TimeSeries],
      past_covariates: Sequence[TimeSeries],
      future_covariates: Sequence[TimeSeries],
      max_samples_per_ts: int,
      **kwargs,
  ):
      """
      Function that fit the model. Deriving classes can override this method for adding additional parameters (e.g.,
      adding validation data), keeping the sanity checks on series performed by fit().
      """
  
      training_samples, training_labels = self._create_lagged_data(
          target_series,
          past_covariates,
          future_covariates,
          max_samples_per_ts,
      )
  
      # if training_labels is of shape (n_samples, 1) flatten it to shape (n_samples,)
      if (
          len(training_labels.shape) == 2
          and training_labels.shape[1] == 1
      ):
          training_labels = training_labels.ravel()
      self.model.fit(training_samples, training_labels, **kwargs)
  
      # generate and store the lagged components names (for feature importance analysis)
      self._lagged_feature_names, _ = create_lagged_component_names(
          target_series=target_series,
          past_covariates=past_covariates,
          future_covariates=future_covariates,
          lags=self._get_lags("target"),
          lags_past_covariates=self._get_lags("past"),
          lags_future_covariates=self._get_lags("future"),
          output_chunk_length=self.output_chunk_length,
          concatenate=False,
          use_static_covariates=self.uses_static_covariates,
      )
  
imports: from collections import OrderedDict
  from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
  import numpy
  import pandas
  from sklearn.linear_model import LinearRegression
  from darts.logging import get_logger, raise_if, raise_if_not, raise_log
  from darts.models.forecasting.forecasting_model import GlobalForecastingModel
  from darts.timeseries import TimeSeries
  from darts.utils.data.tabularization import add_static_covariates_to_lagged_data, create_lagged_component_names, create_lagged_training_data
  from darts.utils.historical_forecasts import _check_optimizable_historical_forecasts_global_models, _optimized_historical_forecasts_all_points, _optimized_historical_forecasts_last_points_only, _process_historical_forecast_input
  from darts.utils.multioutput import MultiOutputRegressor
  from darts.utils.utils import _check_quantiles, get_single_series, seq2series, series2seq
label_desc: Use image node_id 12 for calling the RegressionModel obj's underlying member method code with example usage: obj._fit_model(target_series, past_covariates, future_covariates, max_samples_per_ts) without return types