def _target_average(self, prediction: TimeSeries, series: TimeSeries) -> TimeSeries:
        """Average across the components, keep n_samples, rename components"""
        n_forecasting_models = len(self.forecasting_models)
        n_components = series.n_components
        prediction_values = prediction.all_values(copy=False)
        target_values = np.zeros((
            prediction.n_timesteps,
            n_components,
            prediction.n_samples,
        ))
        for idx_target in range(n_components):
            target_values[:, idx_target] = prediction_values[
                :,
                range(
                    idx_target,
                    n_forecasting_models * n_components,
                    n_components,
                ),
            ].mean(axis=1)

        return TimeSeries.from_times_and_values(
            times=prediction.time_index,
            values=target_values,
            freq=series.freq,
            columns=series.components,
            static_covariates=series.static_covariates,
            hierarchy=series.hierarchy,
            metadata=prediction.metadata,
        )
Average across the components, keep n_samples, rename components
darts/models/forecasting/baselines.py