def _setup_for_fit_from_dataset(
        self,
        series: Union[TimeSeries, Sequence[TimeSeries]],
        past_covariates: Optional[Union[TimeSeries, Sequence[TimeSeries]]] = None,
        future_covariates: Optional[Union[TimeSeries, Sequence[TimeSeries]]] = None,
        sample_weight: Optional[Union[TimeSeries, Sequence[TimeSeries], str]] = None,
        stride: int = 1,
        val_series: Optional[Union[TimeSeries, Sequence[TimeSeries]]] = None,
        val_past_covariates: Optional[Union[TimeSeries, Sequence[TimeSeries]]] = None,
        val_future_covariates: Optional[Union[TimeSeries, Sequence[TimeSeries]]] = None,
        val_sample_weight: Optional[
            Union[TimeSeries, Sequence[TimeSeries], str]
        ] = None,
        trainer: Optional[pl.Trainer] = None,
        verbose: Optional[bool] = None,
        epochs: int = 0,
        max_samples_per_ts: Optional[int] = None,
        dataloader_kwargs: Optional[dict[str, Any]] = None,
    ) -> tuple[
        tuple[
            Sequence[TimeSeries],
            Optional[Sequence[TimeSeries]],
            Optional[Sequence[TimeSeries]],
        ],
        tuple[
            TorchTrainingDataset,
            Optional[TorchTrainingDataset],
            Optional[pl.Trainer],
            Optional[bool],
            int,
            Optional[dict[str, Any]],
        ],
    ]:
        """This method acts on `TimeSeries` inputs. It performs sanity checks, and sets up / returns the datasets and
        additional inputs required for training the model with `fit_from_dataset()`.
        """
        # guarantee that all inputs are either list of `TimeSeries` or `None`
        series = series2seq(series)
        past_covariates = series2seq(past_covariates)
        future_covariates = series2seq(future_covariates)
        val_series = series2seq(val_series)
        val_past_covariates = series2seq(val_past_covariates)
        val_future_covariates = series2seq(val_future_covariates)
        if not isinstance(sample_weight, str):
            sample_weight = series2seq(sample_weight)
        if not isinstance(val_sample_weight, str):
            val_sample_weight = series2seq(val_sample_weight)

        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,
            )
        self._verify_past_future_covariates(
            past_covariates=past_covariates, future_covariates=future_covariates
        )
        if (
            get_single_series(series).static_covariates is not None
            and self.supports_static_covariates
            and self.considers_static_covariates
        ):
            self._verify_static_covariates(get_single_series(series).static_covariates)
            self._uses_static_covariates = True

        if past_covariates is not None:
            self._uses_past_covariates = True
        if future_covariates is not None:
            self._uses_future_covariates = True

        val_series, val_past_covariates, val_future_covariates = (
            self._process_validation_set(
                series=series,
                past_covariates=past_covariates,
                future_covariates=future_covariates,
                val_series=val_series,
                val_past_covariates=val_past_covariates,
                val_future_covariates=val_future_covariates,
            )
        )

        train_dataset = self._build_train_dataset(
            series=series,
            past_covariates=past_covariates,
            future_covariates=future_covariates,
            sample_weight=sample_weight,
            max_samples_per_ts=max_samples_per_ts,
            stride=stride,
        )

        if val_series is not None:
            val_dataset = self._build_train_dataset(
                series=val_series,
                past_covariates=val_past_covariates,
                future_covariates=val_future_covariates,
                sample_weight=val_sample_weight,
                max_samples_per_ts=max_samples_per_ts,
                stride=stride,
            )
        else:
            val_dataset = None

        # proactively catch length exceptions to display nicer messages
        length_ok = True
        try:
            len(train_dataset)
        except ValueError:
            length_ok = False
        raise_if(
            not length_ok or len(train_dataset) == 0,  # mind the order
            "The train dataset does not contain even one training sample. "
            + "This is likely due to the provided training series being too short. "
            + f"This model expect series of length at least {self.min_train_series_length}.",
        )
        logger.info(f"Train dataset contains {len(train_dataset)} samples.")

        series_input = (series, past_covariates, future_covariates)
        fit_from_ds_params = (
            train_dataset,
            val_dataset,
            trainer,
            verbose,
            epochs,
            dataloader_kwargs,
        )
        return series_input, fit_from_ds_params
This method acts on `TimeSeries` inputs. It performs sanity checks, and sets up / returns the datasets and
        additional inputs required for training the model with `fit_from_dataset()`.
        
darts/models/forecasting/torch_forecasting_model.py