def inverse_transform(
        self,
        data: Union[TimeSeries, Sequence[TimeSeries]],
        partial: bool = False,
        series_idx: Optional[Union[int, Sequence[int]]] = None,
    ) -> Union[TimeSeries, Sequence[TimeSeries]]:
        """
        For each data transformer in the pipeline, inverse-transform data. Then inverse transformed data is passed to
        the next transformer. Transformers are traversed in reverse order. Raises value error if not all of the
        transformers are invertible and ``partial`` is set to `False`. Set ``partial`` to True for inverting only the
        InvertibleDataTransformer in the pipeline.

        Parameters
        ----------
        data
            (Sequence of) TimeSeries to be inverse transformed.
        partial
            If set to `True`, the inverse transformation is applied even if the pipeline is not fully invertible,
            calling `inverse_transform()` only on the `InvertibleDataTransformer`s
        series_idx
            Optionally, the index(es) of each series corresponding to their positions within the series used to fit
            the transformer (to retrieve the appropriate transformer parameters).

        Returns
        -------
        Union[TimeSeries, Sequence[TimeSeries]]
            Inverse transformed data.
        """
        if not partial:
            raise_if_not(
                self._invertible,
                "Not all transformers in the pipeline can perform inverse_transform",
                logger,
            )

            for transformer in reversed(self._transformers):
                data = transformer.inverse_transform(data, series_idx=series_idx)
            return data
        else:
            for transformer in reversed(self._transformers):
                if isinstance(transformer, InvertibleDataTransformer):
                    data = transformer.inverse_transform(
                        data,
                        series_idx=series_idx,
                    )
            return data

        For each data transformer in the pipeline, inverse-transform data. Then inverse transformed data is passed to
        the next transformer. Transformers are traversed in reverse order. Raises value error if not all of the
        transformers are invertible and ``partial`` is set to `False`. Set ``partial`` to True for inverting only the
        InvertibleDataTransformer in the pipeline.

        Parameters
        ----------
        data
            (Sequence of) TimeSeries to be inverse transformed.
        partial
            If set to `True`, the inverse transformation is applied even if the pipeline is not fully invertible,
            calling `inverse_transform()` only on the `InvertibleDataTransformer`s
        series_idx
            Optionally, the index(es) of each series corresponding to their positions within the series used to fit
            the transformer (to retrieve the appropriate transformer parameters).

        Returns
        -------
        Union[TimeSeries, Sequence[TimeSeries]]
            Inverse transformed data.
        
darts/dataprocessing/pipeline.py