class_docstr: This class turns any regressor compatible with the scikit-learn API into a
  autoregressive direct multi-step forecaster. A separate model is created for
  each forecast time step. See documentation for more details.
  
  Parameters
  ----------
  regressor : regressor or pipeline compatible with the scikit-learn API
      An instance of a regressor or pipeline compatible with the scikit-learn API.
  steps : int
      Maximum number of future steps the forecaster will predict when using
      method `predict()`. Since a different model is created for each step,
      this value should be defined before training.
  lags : int, list, numpy ndarray, range
      Lags used as predictors. Index starts at 1, so lag 1 is equal to t-1.
  
      - `int`: include lags from 1 to `lags` (included).
      - `list`, `1d numpy ndarray` or `range`: include only lags present in 
      `lags`, all elements must be int.
  transformer_y : object transformer (preprocessor), default `None`
      An instance of a transformer (preprocessor) compatible with the scikit-learn
      preprocessing API with methods: fit, transform, fit_transform and inverse_transform.
      ColumnTransformers are not allowed since they do not have inverse_transform method.
      The transformation is applied to `y` before training the forecaster.
  transformer_exog : object transformer (preprocessor), default `None`
      An instance of a transformer (preprocessor) compatible with the scikit-learn
      preprocessing API. The transformation is applied to `exog` before training the
      forecaster. `inverse_transform` is not available when using ColumnTransformers.
  weight_func : Callable, default `None`
      Function that defines the individual weights for each sample based on the
      index. For example, a function that assigns a lower weight to certain dates.
      Ignored if `regressor` does not have the argument `sample_weight` in its `fit`
      method. The resulting `sample_weight` cannot have negative values.
  fit_kwargs : dict, default `None`
      Additional arguments to be passed to the `fit` method of the regressor.
  n_jobs : int, 'auto', default `'auto'`
      The number of jobs to run in parallel. If `-1`, then the number of jobs is 
      set to the number of cores. If 'auto', `n_jobs` is set using the function
      skforecast.utils.select_n_jobs_fit_forecaster.
      **New in version 0.9.0**
  forecaster_id : str, int, default `None`
      Name used as an identifier of the forecaster.
  
  Attributes
  ----------
  regressor : regressor or pipeline compatible with the scikit-learn API
      An instance of a regressor or pipeline compatible with the scikit-learn API.
      An instance of this regressor is trained for each step. All of them 
      are stored in `self.regressors_`.
  regressors_ : dict
      Dictionary with regressors trained for each step. They are initialized 
      as a copy of `regressor`.
  steps : int
      Number of future steps the forecaster will predict when using method
      `predict()`. Since a different model is created for each step, this value
      should be defined before training.
  lags : numpy ndarray
      Lags used as predictors.
  transformer_y : object transformer (preprocessor)
      An instance of a transformer (preprocessor) compatible with the scikit-learn
      preprocessing API with methods: fit, transform, fit_transform and inverse_transform.
      ColumnTransformers are not allowed since they do not have inverse_transform method.
      The transformation is applied to `y` before training the forecaster.
  transformer_exog : object transformer (preprocessor)
      An instance of a transformer (preprocessor) compatible with the scikit-learn
      preprocessing API. The transformation is applied to `exog` before training the
      forecaster. `inverse_transform` is not available when using ColumnTransformers.
  weight_func : Callable
      Function that defines the individual weights for each sample based on the
      index. For example, a function that assigns a lower weight to certain dates.
      Ignored if `regressor` does not have the argument `sample_weight` in its `fit`
      method. The resulting `sample_weight` cannot have negative values.
  source_code_weight_func : str
      Source code of the custom function used to create weights.
  max_lag : int
      Maximum value of lag included in `lags`.
  window_size : int
      Size of the window needed to create the predictors. It is equal to `max_lag`.
  last_window : pandas Series
      Last window the forecaster has seen during training. It stores the
      values needed to predict the next `step` immediately after the training data.
  index_type : type
      Type of index of the input used in training.
  index_freq : str
      Frequency of Index of the input used in training.
  training_range : pandas Index
      First and last values of index of the data used during training.
  included_exog : bool
      If the forecaster has been trained using exogenous variable/s.
  exog_type : type
      Type of exogenous variable/s used in training.
  exog_dtypes : dict
      Type of each exogenous variable/s used in training. If `transformer_exog` 
      is used, the dtypes are calculated after the transformation.
  exog_col_names : list
      Names of columns of `exog` if `exog` used in training was a pandas
      DataFrame.
  X_train_col_names : list
      Names of columns of the matrix created internally for training.
  fit_kwargs : dict
      Additional arguments to be passed to the `fit` method of the regressor.
  in_sample_residuals : dict
      Residuals of the models when predicting training data. Only stored up to
      1000 values per model in the form `{step: residuals}`. If `transformer_y` 
      is not `None`, residuals are stored in the transformed scale.
  out_sample_residuals : dict
      Residuals of the models when predicting non training data. Only stored
      up to 1000 values per model in the form `{step: residuals}`. If `transformer_y` 
      is not `None`, residuals are assumed to be in the transformed scale. Use 
      `set_out_sample_residuals()` method to set values.
  fitted : bool
      Tag to identify if the regressor has been fitted (trained).
  creation_date : str
      Date of creation.
  fit_date : str
      Date of last fit.
  skforecast_version : str
      Version of skforecast library used to create the forecaster.
  python_version : str
      Version of python used to create the forecaster.
  n_jobs : int, 'auto', default `'auto'`
      The number of jobs to run in parallel. If `-1`, then the number of jobs is 
      set to the number of cores. If 'auto', `n_jobs` is set using the function
      skforecast.utils.select_n_jobs_fit_forecaster.
      **New in version 0.9.0**
  forecaster_id : str, int
      Name used as an identifier of the forecaster.
  
  Notes
  -----
  A separate model is created for each forecasting time step. It is important to
  note that all models share the same parameter and hyperparameter configuration.
   
class_docstr_tok: ["This","class","turns","any","regressor","compatible","with","the","scikit-learn","API","into","a","autoregressive","direct","multi-step","forecaster",".","A","separate","model","is","created","for","each","forecast","time","step",".","See","documentation","for","more","details",".","Parameters","--","--","--","--","--","regressor",":","regressor","or","pipeline","compatible","with","the","scikit-learn","API","An","instance","of","a","regressor","or","pipeline","compatible","with","the","scikit-learn","API",".","steps",":","int","Maximum","number","of","future","steps","the","forecaster","will","predict","when","using","method","`","predict","(",")","`",".","Since","a","different","model","is","created","for","each","step",",","this","value","should","be","defined","before","training",".","lags",":","int",",","list",",","numpy","ndarray",",","range","Lags","used","as","predictors",".","Index","starts","at","1",",","so","lag","1","is","equal","to","t-1",".","-","`","int","`",":","include","lags","from","1","to","`","lags","`","(","included",")",".","-","`","list","`",",","`","1d","numpy","ndarray","`","or","`","range","`",":","include","only","lags","present","in","`","lags","`",",","all","elements","must","be","int",".","transformer_y",":","object","transformer","(","preprocessor",")",",","default","`","None","`","An","instance","of","a","transformer","(","preprocessor",")","compatible","with","the","scikit-learn","preprocessing","API","with","methods",":","fit",",","transform",",","fit_transform","and","inverse_transform",".","ColumnTransformers","are","not","allowed","since","they","do","not","have","inverse_transform","method",".","The","transformation","is","applied","to","`","y","`","before","training","the","forecaster",".","transformer_exog",":","object","transformer","(","preprocessor",")",",","default","`","None","`","An","instance","of","a","transformer","(","preprocessor",")","compatible","with","the","scikit-learn","preprocessing","API",".","The","transformation","is","applied","to","`","exog","`","before","training","the","forecaster",".","`","inverse_transform","`","is","not","available","when","using","ColumnTransformers",".","weight_func",":","Callable",",","default","`","None","`","Function","that","defines","the","individual","weights","for","each","sample","based","on","the","index",".","For","example",",","a","function","that","assigns","a","lower","weight","to","certain","dates",".","Ignored","if","`","regressor","`","does","not","have","the","argument","`","sample_weight","`","in","its","`","fit","`","method",".","The","resulting","`","sample_weight","`","can","not","have","negative","values",".","fit_kwargs",":","dict",",","default","`","None","`","Additional","arguments","to","be","passed","to","the","`","fit","`","method","of","the","regressor",".","n_jobs",":","int",",","'auto","'",",","default","`","'auto","'","`","The","number","of","jobs","to","run","in","parallel",".","If","`","-1","`",",","then","the","number","of","jobs","is","set","to","the","number","of","cores",".","If","'auto","'",",","`","n_jobs","`","is","set","using","the","function","skforecast.utils.select_n_jobs_fit_forecaster",".","*","*","New","in","version","0.9.0","*","*","forecaster_id",":","str",",","int",",","default","`","None","`","Name","used","as","an","identifier","of","the","forecaster",".","Attributes","--","--","--","--","--","regressor",":","regressor","or","pipeline","compatible","with","the","scikit-learn","API","An","instance","of","a","regressor","or","pipeline","compatible","with","the","scikit-learn","API",".","An","instance","of","this","regressor","is","trained","for","each","step",".","All","of","them","are","stored","in","`","self.regressors_","`",".","regressors_",":","dict","Dictionary","with","regressors","trained","for","each","step",".","They","are","initialized","as","a","copy","of","`","regressor","`",".","steps",":","int","Number","of","future","steps","the","forecaster","will","predict","when","using","method","`","predict","(",")","`",".","Since","a","different","model","is","created","for","each","step",",","this","value","should","be","defined","before","training",".","lags",":","numpy","ndarray","Lags","used","as","predictors",".","transformer_y",":","object","transformer","(","preprocessor",")","An","instance","of","a","transformer","(","preprocessor",")","compatible","with","the","scikit-learn","preprocessing","API","with","methods",":","fit",",","transform",",","fit_transform","and","inverse_transform",".","ColumnTransformers","are","not","allowed","since","they","do","not","have","inverse_transform","method",".","The","transformation","is","applied","to","`","y","`","before","training","the","forecaster",".","transformer_exog",":","object","transformer","(","preprocessor",")","An","instance","of","a","transformer","(","preprocessor",")","compatible","with","the","scikit-learn","preprocessing","API",".","The","transformation","is","applied","to","`","exog","`","before","training","the","forecaster",".","`","inverse_transform","`","is","not","available","when","using","ColumnTransformers",".","weight_func",":","Callable","Function","that","defines","the","individual","weights","for","each","sample","based","on","the","index",".","For","example",",","a","function","that","assigns","a","lower","weight","to","certain","dates",".","Ignored","if","`","regressor","`","does","not","have","the","argument","`","sample_weight","`","in","its","`","fit","`","method",".","The","resulting","`","sample_weight","`","can","not","have","negative","values",".","source_code_weight_func",":","str","Source","code","of","the","custom","function","used","to","create","weights",".","max_lag",":","int","Maximum","value","of","lag","included","in","`","lags","`",".","window_size",":","int","Size","of","the","window","needed","to","create","the","predictors",".","It","is","equal","to","`","max_lag","`",".","last_window",":","pandas","Series","Last","window","the","forecaster","has","seen","during","training",".","It","stores","the","values","needed","to","predict","the","next","`","step","`","immediately","after","the","training","data",".","index_type",":","type","Type","of","index","of","the","input","used","in","training",".","index_freq",":","str","Frequency","of","Index","of","the","input","used","in","training",".","training_range",":","pandas","Index","First","and","last","values","of","index","of","the","data","used","during","training",".","included_exog",":","bool","If","the","forecaster","has","been","trained","using","exogenous","variable\/s",".","exog_type",":","type","Type","of","exogenous","variable\/s","used","in","training",".","exog_dtypes",":","dict","Type","of","each","exogenous","variable\/s","used","in","training",".","If","`","transformer_exog","`","is","used",",","the","dtypes","are","calculated","after","the","transformation",".","exog_col_names",":","list","Names","of","columns","of","`","exog","`","if","`","exog","`","used","in","training","was","a","pandas","DataFrame",".","X_train_col_names",":","list","Names","of","columns","of","the","matrix","created","internally","for","training",".","fit_kwargs",":","dict","Additional","arguments","to","be","passed","to","the","`","fit","`","method","of","the","regressor",".","in_sample_residuals",":","dict","Residuals","of","the","models","when","predicting","training","data",".","Only","stored","up","to","1000","values","per","model","in","the","form","`","{","step",":","residuals","}","`",".","If","`","transformer_y","`","is","not","`","None","`",",","residuals","are","stored","in","the","transformed","scale",".","out_sample_residuals",":","dict","Residuals","of","the","models","when","predicting","non","training","data",".","Only","stored","up","to","1000","values","per","model","in","the","form","`","{","step",":","residuals","}","`",".","If","`","transformer_y","`","is","not","`","None","`",",","residuals","are","assumed","to","be","in","the","transformed","scale",".","Use","`","set_out_sample_residuals","(",")","`","method","to","set","values",".","fitted",":","bool","Tag","to","identify","if","the","regressor","has","been","fitted","(","trained",")",".","creation_date",":","str","Date","of","creation",".","fit_date",":","str","Date","of","last","fit",".","skforecast_version",":","str","Version","of","skforecast","library","used","to","create","the","forecaster",".","python_version",":","str","Version","of","python","used","to","create","the","forecaster",".","n_jobs",":","int",",","'auto","'",",","default","`","'auto","'","`","The","number","of","jobs","to","run","in","parallel",".","If","`","-1","`",",","then","the","number","of","jobs","is","set","to","the","number","of","cores",".","If","'auto","'",",","`","n_jobs","`","is","set","using","the","function","skforecast.utils.select_n_jobs_fit_forecaster",".","*","*","New","in","version","0.9.0","*","*","forecaster_id",":","str",",","int","Name","used","as","an","identifier","of","the","forecaster",".","Notes","--","--","-","A","separate","model","is","created","for","each","forecasting","time","step",".","It","is","important","to","note","that","all","models","share","the","same","parameter","and","hyperparameter","configuration","."]
docstr: Select the columns needed to train a forecaster for a specific step.  
  The input matrices should be created using `create_train_X_y` method. 
  This method updates the index of `X_train` to the corresponding one 
  according to `y_train`. If `remove_suffix=True` the suffix "_step_i" 
  will be removed from the column names. 
  
  Parameters
  ----------
  step : int
      Step for which columns must be selected selected. Starts at 1.
  X_train : pandas DataFrame
      Dataframe created with the `create_train_X_y` method, first return.
  y_train : dict
      Dict created with the `create_train_X_y` method, second return.
  remove_suffix : bool, default `False`
      If True, suffix "_step_i" is removed from the column names.
  
  Returns
  -------
  X_train_step : pandas DataFrame
      Training values (predictors) for the selected step.
  y_train_step : pandas Series
      Values (target) of the time series related to each row of `X_train`.
      Shape: (len(y) - self.max_lag)
docstr_tok: ["Select","the","columns","needed","to","train","a","forecaster","for","a","specific","step",".","The","input","matrices","should","be","created","using","`","create_train_X_y","`","method",".","This","method","updates","the","index","of","`","X_train","`","to","the","corresponding","one","according","to","`","y_train","`",".","If","`","remove_suffix=True","`","the","suffix","``","_step_i","''","will","be","removed","from","the","column","names",".","Parameters","--","--","--","--","--","step",":","int","Step","for","which","columns","must","be","selected","selected",".","Starts","at","1",".","X_train",":","pandas","DataFrame","Dataframe","created","with","the","`","create_train_X_y","`","method",",","first","return",".","y_train",":","dict","Dict","created","with","the","`","create_train_X_y","`","method",",","second","return",".","remove_suffix",":","bool",",","default","`","False","`","If","True",",","suffix","``","_step_i","''","is","removed","from","the","column","names",".","Returns","--","--","--","-","X_train_step",":","pandas","DataFrame","Training","values","(","predictors",")","for","the","selected","step",".","y_train_step",":","pandas","Series","Values","(","target",")","of","the","time","series","related","to","each","row","of","`","X_train","`",".","Shape",":","(","len","(","y",")","-","self.max_lag",")"]
code: def filter_train_X_y_for_step(
      self,
      step: int,
      X_train: pd.DataFrame,
      y_train: dict,
      remove_suffix: bool = False,
  ) -> Tuple[pd.DataFrame, pd.Series]:
      """
      Select the columns needed to train a forecaster for a specific step.
      The input matrices should be created using `create_train_X_y` method.
      This method updates the index of `X_train` to the corresponding one
      according to `y_train`. If `remove_suffix=True` the suffix "_step_i"
      will be removed from the column names.
  
      Parameters
      ----------
      step : int
          Step for which columns must be selected selected. Starts at 1.
      X_train : pandas DataFrame
          Dataframe created with the `create_train_X_y` method, first return.
      y_train : dict
          Dict created with the `create_train_X_y` method, second return.
      remove_suffix : bool, default `False`
          If True, suffix "_step_i" is removed from the column names.
  
      Returns
      -------
      X_train_step : pandas DataFrame
          Training values (predictors) for the selected step.
      y_train_step : pandas Series
          Values (target) of the time series related to each row of `X_train`.
          Shape: (len(y) - self.max_lag)
  
      """
  
      if (step < 1) or (step > self.steps):
          raise ValueError(
              (
                  f"Invalid value `step`. For this forecaster, minimum value is 1 "
                  f"and the maximum step is {self.steps}."
              )
          )
  
      y_train_step = y_train[step]
  
      # Matrix X_train starts at index 0.
      if not self.included_exog:
          X_train_step = X_train
      else:
          idx_columns_lags = np.arange(len(self.lags))
          n_exog = (
              len(self.X_train_col_names) - len(self.lags)
          ) / self.steps
          idx_columns_exog = (
              np.arange((step - 1) * n_exog, (step) * n_exog)
              + idx_columns_lags[-1]
              + 1
          )
          idx_columns = np.hstack((idx_columns_lags, idx_columns_exog))
          X_train_step = X_train.iloc[:, idx_columns]
  
      X_train_step.index = y_train_step.index
  
      if remove_suffix:
          X_train_step.columns = [
              col_name.replace(f"_step_{step}", "")
              for col_name in X_train_step.columns
          ]
          y_train_step.name = y_train_step.name.replace(
              f"_step_{step}", ""
          )
  
      return X_train_step, y_train_step
  
imports: from typing import Union, Dict, List, Tuple, Optional, Callable
  import warnings
  import logging
  import sys
  import numpy
  import pandas
  import sklearn
  import sklearn.pipeline
  from sklearn.base import clone
  import inspect
  from copy import copy
  from joblib import Parallel, delayed, cpu_count
  import skforecast
  from ..ForecasterBase import ForecasterBase
  from ..utils import initialize_lags
  from ..utils import initialize_weights
  from ..utils import check_select_fit_kwargs
  from ..utils import check_y
  from ..utils import check_exog
  from ..utils import get_exog_dtypes
  from ..utils import check_exog_dtypes
  from ..utils import check_predict_input
  from ..utils import check_interval
  from ..utils import preprocess_y
  from ..utils import preprocess_last_window
  from ..utils import preprocess_exog
  from ..utils import exog_to_direct
  from ..utils import exog_to_direct_numpy
  from ..utils import expand_index
  from ..utils import transform_series
  from ..utils import transform_dataframe
  from ..utils import select_n_jobs_fit_forecaster
label_desc: Use image node_id 5 for calling the ForecasterAutoregDirect obj's underlying member method code with example usage: obj.filter_train_X_y_for_step(step, X_train, y_train, remove_suffix) and returns: X_train_step,  y_train_step