def unapply_component_mask(
        series: Union[TimeSeries, Sequence[TimeSeries]],
        vals: Union[np.ndarray, Sequence[np.ndarray], TimeSeries, Sequence[TimeSeries]],
        component_mask: Optional[np.ndarray] = None,
    ) -> Union[np.ndarray, Sequence[np.ndarray], TimeSeries, Sequence[TimeSeries]]:
        """
        Adds back components previously removed by `component_mask` in `apply_component_mask` method.

        Parameters
        ----------
        series
            input TimeSeries that was fed into transformer.
        vals:
            `np.ndarray` or `TimeSeries` to 'unmask'
        component_mask
            Optionally, np.ndarray boolean mask of shape (n_components, 1) specifying which components were extracted
            from `series`. If given, insert `vals` back into the columns of the original array. If not specified,
            nothing is 'unmasked'.

        Returns
        -------
        unmasked
            `TimeSeries` (if `vals` is a `TimeSeries`) or `np.ndarray` (if `vals` is an `np.ndarray`) with those
            components previously removed by `component_mask` now 'added back'.
        """
        if component_mask is None:
            return vals

        if not (
            isinstance(component_mask, np.ndarray) and component_mask.dtype == bool
        ):
            raise_log(
                ValueError(
                    "If `component_mask` is given, must be a boolean np.ndarray`"
                ),
                logger=logger,
            )

        sequence_type_in = get_series_seq_type(series)
        called_with_single_series = sequence_type_in == SeriesType.SINGLE
        series = series2seq(series)
        if called_with_single_series:
            vals = [vals]

        out = []
        for series_, vals_ in zip(series, vals):
            if not series_.width == len(component_mask):
                raise_log(
                    ValueError(
                        "mismatch between number of components in `series` and length of `component_mask`"
                    ),
                    logger=logger,
                )
            unmasked = series_.all_values()
            if isinstance(vals_, TimeSeries):
                unmasked[:, component_mask, :] = vals_.all_values()
                # Remove timepoints not present in transformed data:
                unmasked = series_.slice_intersect(vals_).with_values(unmasked)
            else:
                unmasked[:, component_mask, :] = vals_

            out.append(unmasked)
        return out[0] if called_with_single_series else out

        Adds back components previously removed by `component_mask` in `apply_component_mask` method.

        Parameters
        ----------
        series
            input TimeSeries that was fed into transformer.
        vals:
            `np.ndarray` or `TimeSeries` to 'unmask'
        component_mask
            Optionally, np.ndarray boolean mask of shape (n_components, 1) specifying which components were extracted
            from `series`. If given, insert `vals` back into the columns of the original array. If not specified,
            nothing is 'unmasked'.

        Returns
        -------
        unmasked
            `TimeSeries` (if `vals` is a `TimeSeries`) or `np.ndarray` (if `vals` is an `np.ndarray`) with those
            components previously removed by `component_mask` now 'added back'.
        
darts/dataprocessing/transformers/base_data_transformer.py