def component_masking(transformer_method):
    """Applies component masking to the series fed to any `transform` method, and then reverts the masking for the
    final output series.
    """

    @wraps(transformer_method)
    def transform_wrapper(
        cls, series: TimeSeries, params: Mapping[str, Any], *args, **kwargs
    ):
        kwargs = copy.deepcopy(kwargs)
        # `mask_components` and `component_mask` must be in `kwargs`
        mask_components = kwargs.pop("mask_components")
        mask_components_apply_only = kwargs.pop("mask_components_apply_only")
        component_mask = kwargs.pop("component_mask")

        # remove non-transform columns
        if mask_components and component_mask is not None:
            series_proc = BaseDataTransformer.apply_component_mask(
                series, component_mask, return_ts=True
            )
        else:
            series_proc = series
            if component_mask is not None:
                kwargs["component_mask"] = component_mask

        out = transformer_method(cls, series_proc, params, *args, **kwargs)

        # add back non-transformed columns
        if mask_components and not mask_components_apply_only:
            out = BaseDataTransformer.unapply_component_mask(
                series, out, component_mask
            )
        return out

    return transform_wrapper
Applies component masking to the series fed to any `transform` method, and then reverts the masking for the
    final output series.
    
darts/dataprocessing/transformers/base_data_transformer.py