def _setup_trainer(
        self,
        trainer: Optional[pl.Trainer],
        model: PLForecastingModule,
        verbose: Optional[bool] = None,
        epochs: int = 0,
    ) -> pl.Trainer:
        """Sets up a PyTorch-Lightning trainer (if not already provided) for training or prediction."""
        if trainer is not None:
            return trainer

        trainer_params = {key: val for key, val in self.trainer_params.items()}
        has_progress_bar = any([
            isinstance(cb, ProgressBar) for cb in trainer_params.get("callbacks", [])
        ])
        # we ignore `verbose` if `trainer` has a progress bar, to avoid errors from lightning
        if verbose is not None and not has_progress_bar:
            trainer_params["enable_model_summary"] = (
                verbose if model.epochs_trained == 0 else False
            )
            trainer_params["enable_progress_bar"] = verbose

        return self._init_trainer(trainer_params=trainer_params, max_epochs=epochs)
Sets up a PyTorch-Lightning trainer (if not already provided) for training or prediction.
darts/models/forecasting/torch_forecasting_model.py