docstr: Fit/train the model on one or multiple series.
  
  Parameters
  ----------
  series
      TimeSeries or Sequence[TimeSeries] object containing the target values.
  past_covariates
      Optionally, a series or sequence of series specifying past-observed covariates
  future_covariates
      Optionally, a series or sequence of series specifying future-known covariates
  max_samples_per_ts
      This is an integer upper bound on the number of tuples that can be produced
      per time series. It can be used in order to have an upper bound on the total size of the dataset and
      ensure proper sampling. If `None`, it will read all of the individual time series in advance (at dataset
      creation) to know their sizes, which might be expensive on big datasets.
      If some series turn out to have a length that would allow more than `max_samples_per_ts`, only the
      most recent `max_samples_per_ts` samples will be considered.
  n_jobs_multioutput_wrapper
      Number of jobs of the MultiOutputRegressor wrapper to run in parallel. Only used if the model doesn't
      support multi-output regression natively.
  **kwargs
      Additional keyword arguments passed to the `fit` method of the model.
docstr_tok: ["Fit\/train","the","model","on","one","or","multiple","series",".","Parameters","--","--","--","--","--","series","TimeSeries","or","Sequence","[","TimeSeries","]","object","containing","the","target","values",".","past_covariates","Optionally",",","a","series","or","sequence","of","series","specifying","past-observed","covariates","future_covariates","Optionally",",","a","series","or","sequence","of","series","specifying","future-known","covariates","max_samples_per_ts","This","is","an","integer","upper","bound","on","the","number","of","tuples","that","can","be","produced","per","time","series",".","It","can","be","used","in","order","to","have","an","upper","bound","on","the","total","size","of","the","dataset","and","ensure","proper","sampling",".","If","`","None","`",",","it","will","read","all","of","the","individual","time","series","in","advance","(","at","dataset","creation",")","to","know","their","sizes",",","which","might","be","expensive","on","big","datasets",".","If","some","series","turn","out","to","have","a","length","that","would","allow","more","than","`","max_samples_per_ts","`",",","only","the","most","recent","`","max_samples_per_ts","`","samples","will","be","considered",".","n_jobs_multioutput_wrapper","Number","of","jobs","of","the","MultiOutputRegressor","wrapper","to","run","in","parallel",".","Only","used","if","the","model","doesn't","support","multi-output","regression","natively",".","*","*","kwargs","Additional","keyword","arguments","passed","to","the","`","fit","`","method","of","the","model","."]
code: def fit(
      self,
      series: Union[TimeSeries, Sequence[TimeSeries]],
      past_covariates: Optional[
          Union[TimeSeries, Sequence[TimeSeries]]
      ] = None,
      future_covariates: Optional[
          Union[TimeSeries, Sequence[TimeSeries]]
      ] = None,
      max_samples_per_ts: Optional[int] = None,
      n_jobs_multioutput_wrapper: Optional[int] = None,
      **kwargs,
  ):
      """
      Fit/train the model on one or multiple series.
  
      Parameters
      ----------
      series
          TimeSeries or Sequence[TimeSeries] object containing the target values.
      past_covariates
          Optionally, a series or sequence of series specifying past-observed covariates
      future_covariates
          Optionally, a series or sequence of series specifying future-known covariates
      max_samples_per_ts
          This is an integer upper bound on the number of tuples that can be produced
          per time series. It can be used in order to have an upper bound on the total size of the dataset and
          ensure proper sampling. If `None`, it will read all of the individual time series in advance (at dataset
          creation) to know their sizes, which might be expensive on big datasets.
          If some series turn out to have a length that would allow more than `max_samples_per_ts`, only the
          most recent `max_samples_per_ts` samples will be considered.
      n_jobs_multioutput_wrapper
          Number of jobs of the MultiOutputRegressor wrapper to run in parallel. Only used if the model doesn't
          support multi-output regression natively.
      **kwargs
          Additional keyword arguments passed to the `fit` method of the model.
      """
      # guarantee that all inputs are either list of TimeSeries or None
      series = series2seq(series)
      past_covariates = series2seq(past_covariates)
      future_covariates = series2seq(future_covariates)
  
      self._verify_static_covariates(series[0].static_covariates)
  
      self.encoders = self.initialize_encoders()
      if self.encoders.encoding_available:
          (
              past_covariates,
              future_covariates,
          ) = self.generate_fit_encodings(
              series=series,
              past_covariates=past_covariates,
              future_covariates=future_covariates,
          )
  
      if past_covariates is not None:
          self._uses_past_covariates = True
      if future_covariates is not None:
          self._uses_future_covariates = True
      if (
          get_single_series(series).static_covariates is not None
          and self.supports_static_covariates
          and self.considers_static_covariates
      ):
          self._uses_static_covariates = True
  
      for covs, name in zip(
          [past_covariates, future_covariates], ["past", "future"]
      ):
          raise_if(
              covs is not None and name not in self.lags,
              f"`{name}_covariates` not None in `fit()` method call, but `lags_{name}_covariates` is None in "
              f"constructor.",
          )
  
          raise_if(
              covs is None and name in self.lags,
              f"`{name}_covariates` is None in `fit()` method call, but `lags_{name}_covariates` is not None in "
              "constructor.",
          )
  
      # saving the dims of all input series to check at prediction time
      self.input_dim = {
          "target": series[0].width,
          "past": past_covariates[0].width if past_covariates else None,
          "future": future_covariates[0].width
          if future_covariates
          else None,
      }
  
      # if multi-output regression
      if not series[0].is_univariate or (
          self.output_chunk_length > 1 and self.multi_models
      ):
          # and model isn't wrapped already
          if not isinstance(self.model, MultiOutputRegressor):
              # check whether model supports multi-output regression natively
              if not (
                  callable(getattr(self.model, "_get_tags", None))
                  and isinstance(self.model._get_tags(), dict)
                  and self.model._get_tags().get("multioutput")
              ):
                  # if not, wrap model with MultiOutputRegressor
                  self.model = MultiOutputRegressor(
                      self.model, n_jobs=n_jobs_multioutput_wrapper
                  )
              elif self.model.__class__.__name__ == "CatBoostRegressor":
                  if (
                      self.model.get_params()["loss_function"]
                      == "RMSEWithUncertainty"
                  ):
                      self.model = MultiOutputRegressor(
                          self.model, n_jobs=n_jobs_multioutput_wrapper
                      )
  
      # warn if n_jobs_multioutput_wrapper was provided but not used
      if (
          not isinstance(self.model, MultiOutputRegressor)
          and n_jobs_multioutput_wrapper is not None
      ):
          logger.warning(
              "Provided `n_jobs_multioutput_wrapper` wasn't used."
          )
  
      super().fit(
          series=seq2series(series),
          past_covariates=seq2series(past_covariates),
          future_covariates=seq2series(future_covariates),
      )
      variate2arg = {
          "target": "lags",
          "past": "lags_past_covariates",
          "future": "lags_future_covariates",
      }
  
      # if provided, component-wise lags must be defined for all the components of the first series
      component_lags_error_msg = []
      for variate_type, variate in zip(
          ["target", "past", "future"],
          [series, past_covariates, future_covariates],
      ):
          if variate_type not in self.component_lags:
              continue
  
          # ignore the fallback lags entry
          provided_components = set(
              self.component_lags[variate_type].keys()
          )
          required_components = set(variate[0].components)
  
          wrong_components = list(
              provided_components
              - {"default_lags"}
              - required_components
          )
          missing_keys = list(required_components - provided_components)
          # lags were specified for unrecognized components
          if len(wrong_components) > 0:
              component_lags_error_msg.append(
                  f"The `{variate2arg[variate_type]}` dictionary specifies lags for components that are not "
                  f"present in the series : {wrong_components}. They must be removed to avoid any ambiguity."
              )
          elif (
              len(missing_keys) > 0
              and "default_lags" not in provided_components
          ):
              component_lags_error_msg.append(
                  f"The {variate2arg[variate_type]} dictionary is missing the lags for the following components "
                  f"present in the series: {missing_keys}. The key 'default_lags' can be used to provide lags for "
                  f"all the non-explicitely defined components."
              )
          else:
              # reorder the components based on the input series, insert the default when necessary
              self.component_lags[variate_type] = {
                  comp_name: self.component_lags[variate_type][
                      comp_name
                  ]
                  if comp_name in self.component_lags[variate_type]
                  else self.component_lags[variate_type]["default_lags"]
                  for comp_name in variate[0].components
              }
  
      # single error message for all the lags arguments
      if len(component_lags_error_msg) > 0:
          raise_log(
              ValueError("\n".join(component_lags_error_msg)), logger
          )
  
      self._fit_model(
          series,
          past_covariates,
          future_covariates,
          max_samples_per_ts,
          **kwargs,
      )
  
      return self
  
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 13 for calling the RegressionModel obj's underlying member method code with example usage: obj.fit(series, past_covariates, future_covariates, max_samples_per_ts, n_jobs_multioutput_wrapper) and returns: self