def _extract_component_lags_autoregression(
    series_type: str,
    values_matrix: np.ndarray,
    shift: int,
    last_step_shift: int,
    t_pred: int,
    lags: dict[str, list[int]],
    component_lags: dict[str, dict[str, list[int]]],
) -> np.ndarray:
    """Extract, concatenate and reorder component-wise lags to obtain a feature order
    identical to tabularization.
    """
    # prepare index to reorder features by lags across components
    comp_lags_reordered = np.concatenate([
        comp_lags for comp_lags in component_lags[series_type].values()
    ]).argsort(**STABLE_SORT_KWARGS)

    # convert relative lags to absolute
    if series_type == "target":
        lags_shift = -shift - last_step_shift
    else:
        lags_shift = -lags[series_type][0] + t_pred

    # extract features
    tmp_X = [
        values_matrix[
            :,
            [lag + lags_shift for lag in comp_lags],
            comp_i,
        ]
        for comp_i, comp_lags in enumerate(component_lags[series_type].values())
    ]

    # concatenate on features dimension and reorder
    return np.concatenate(tmp_X, axis=1)[:, comp_lags_reordered]
Extract, concatenate and reorder component-wise lags to obtain a feature order
    identical to tabularization.
    
darts/utils/data/tabularization/tabularization.py