def inverse_transform(
        self,
        series: Union[TimeSeries, Sequence[TimeSeries], Sequence[Sequence[TimeSeries]]],
        *args,
        component_mask: Optional[np.array] = None,
        series_idx: Optional[Union[int, Sequence[int]]] = None,
        **kwargs,
    ) -> Union[TimeSeries, list[TimeSeries], list[list[TimeSeries]]]:
        """Inverse transforms a (sequence of) series by calling the user-implemented `ts_inverse_transform` method.

        In case a sequence or list of lists is passed as input data, this function takes care of parallelising the
        transformation of multiple series in the sequence at the same time. Additionally,
        if the `mask_components` attribute was set to `True` when instantiating `InvertibleDataTransformer`,
        then any provided `component_mask`s will be automatically applied to each input `TimeSeries`;
        please refer to 'Notes' for further details on component masking.

        Any additionally specified `*args` and `**kwargs` are automatically passed to `ts_inverse_transform`.

        Parameters
        ----------
        series
            The series to inverse-transform.
            If a single `TimeSeries`, returns a single series.
            If a sequence of `TimeSeries`, returns a list of series. The series should be in the same order as the
            sequence used to fit the transformer.
            If a list of lists of `TimeSeries`, returns a list of lists of series. This can for example be the output
            of `ForecastingModel.historical_forecasts()` when using multiple series. Each inner list should contain
            `TimeSeries` related to the same series. The order of inner lists should be the same as the sequence used
            to fit the transformer.
        args
            Additional positional arguments for the :func:`ts_inverse_transform()` method
        component_mask : Optional[np.ndarray] = None
            Optionally, a 1-D boolean np.ndarray of length ``series.n_components`` that specifies
            which components of the underlying `series` the inverse transform should consider.
        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).
        kwargs
            Additional keyword arguments for the :func:`ts_inverse_transform()` method

        Returns
        -------
        Union[TimeSeries, List[TimeSeries], List[List[TimeSeries]]]
            Inverse transformed data.

        Notes
        -----
        If the `mask_components` attribute was set to `True` when instantiating `InvertibleDataTransformer`,
        then any provided `component_mask`s will be automatically applied to each `TimeSeries` input to
        transform; `component_mask`s are simply boolean arrays of shape `(series.n_components,)` that
        specify which components of each `series` should be transformed using `ts_inverse_transform` and which
        components should not. If `component_mask[i]` is `True`, then the `i`th component of each
        `series` will be transformed by `ts_inverse_transform`. Conversely, if `component_mask[i]` is `False`,
        the `i`th component will be removed from each `series` before being passed to `ts_inverse_transform`;
        after transforming this masked series, the untransformed `i`th component will be 'added back'
        to the output. Note that automatic `component_mask`ing can only be performed if the `ts_inverse_transform`
        does *not* change the number of timesteps in each series; if this were to happen, then the transformed
        and untransformed components are unable to be concatenated back together along the component axis.

        If `mask_components` was set to `False` when instantiating `InvertibleDataTransformer`, then any provided
        `component_masks` will be passed as a keyword argument `ts_inverse_transform`; the user can then manually
        specify how the `component_mask` should be applied to each series.
        """
        if hasattr(self, "_fit_called") and not self._fit_called:
            raise_log(
                ValueError("fit() must have been called before inverse_transform()"),
                logger=logger,
            )

        desc = f"Inverse ({self._name})"

        # Take note of original input for unmasking purposes:
        called_with_single_series = False
        called_with_sequence_series = False
        series_specified = series_idx is not None
        if isinstance(series, TimeSeries):
            data = [series]
            if series_specified:
                transformer_selector = self._process_series_idx(series_idx)
            else:
                transformer_selector = [0]
            called_with_single_series = True
        elif isinstance(series[0], TimeSeries):  # Sequence[TimeSeries]
            data = series
            if series_specified:
                transformer_selector = self._process_series_idx(series_idx)
            else:
                transformer_selector = range(len(series))
            called_with_sequence_series = True
        else:  # Sequence[Sequence[TimeSeries]]
            data = []
            transformer_selector = []
            if series_specified:
                iterator_ = zip(self._process_series_idx(series_idx), series)
            else:
                iterator_ = enumerate(series)
            for idx, series_list in iterator_:
                data.extend(series_list)
                transformer_selector += [idx] * len(series_list)

        input_iterator = _build_tqdm_iterator(
            zip(
                data,
                self._get_params(
                    transformer_selector=transformer_selector,
                    series_specified=series_specified,
                ),
            ),
            verbose=self._verbose,
            desc=desc,
            total=len(transformer_selector),
        )

        # apply & unapply component masking to the transform method
        kwargs["mask_components"] = self._mask_components
        kwargs["mask_components_apply_only"] = False
        kwargs["component_mask"] = component_mask

        transformed_data = _parallel_apply(
            input_iterator,
            self._ts_inverse_transform,
            self._n_jobs,
            args,
            kwargs,
        )

        if called_with_single_series:
            return transformed_data[0]
        elif called_with_sequence_series:
            return transformed_data
        else:
            cum_len = np.cumsum([0] + [len(s_) for s_ in series])
            return [
                transformed_data[cum_len[i] : cum_len[i + 1]]
                for i in range(len(cum_len) - 1)
            ]
Inverse transforms a (sequence of) series by calling the user-implemented `ts_inverse_transform` method.

        In case a sequence or list of lists is passed as input data, this function takes care of parallelising the
        transformation of multiple series in the sequence at the same time. Additionally,
        if the `mask_components` attribute was set to `True` when instantiating `InvertibleDataTransformer`,
        then any provided `component_mask`s will be automatically applied to each input `TimeSeries`;
        please refer to 'Notes' for further details on component masking.

        Any additionally specified `*args` and `**kwargs` are automatically passed to `ts_inverse_transform`.

        Parameters
        ----------
        series
            The series to inverse-transform.
            If a single `TimeSeries`, returns a single series.
            If a sequence of `TimeSeries`, returns a list of series. The series should be in the same order as the
            sequence used to fit the transformer.
            If a list of lists of `TimeSeries`, returns a list of lists of series. This can for example be the output
            of `ForecastingModel.historical_forecasts()` when using multiple series. Each inner list should contain
            `TimeSeries` related to the same series. The order of inner lists should be the same as the sequence used
            to fit the transformer.
        args
            Additional positional arguments for the :func:`ts_inverse_transform()` method
        component_mask : Optional[np.ndarray] = None
            Optionally, a 1-D boolean np.ndarray of length ``series.n_components`` that specifies
            which components of the underlying `series` the inverse transform should consider.
        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).
        kwargs
            Additional keyword arguments for the :func:`ts_inverse_transform()` method

        Returns
        -------
        Union[TimeSeries, List[TimeSeries], List[List[TimeSeries]]]
            Inverse transformed data.

        Notes
        -----
        If the `mask_components` attribute was set to `True` when instantiating `InvertibleDataTransformer`,
        then any provided `component_mask`s will be automatically applied to each `TimeSeries` input to
        transform; `component_mask`s are simply boolean arrays of shape `(series.n_components,)` that
        specify which components of each `series` should be transformed using `ts_inverse_transform` and which
        components should not. If `component_mask[i]` is `True`, then the `i`th component of each
        `series` will be transformed by `ts_inverse_transform`. Conversely, if `component_mask[i]` is `False`,
        the `i`th component will be removed from each `series` before being passed to `ts_inverse_transform`;
        after transforming this masked series, the untransformed `i`th component will be 'added back'
        to the output. Note that automatic `component_mask`ing can only be performed if the `ts_inverse_transform`
        does *not* change the number of timesteps in each series; if this were to happen, then the transformed
        and untransformed components are unable to be concatenated back together along the component axis.

        If `mask_components` was set to `False` when instantiating `InvertibleDataTransformer`, then any provided
        `component_masks` will be passed as a keyword argument `ts_inverse_transform`; the user can then manually
        specify how the `component_mask` should be applied to each series.
        
darts/dataprocessing/transformers/invertible_data_transformer.py