def fit(
        self,
        series: Union[TimeSeries, Sequence[TimeSeries]],
        *args,
        component_mask: Optional[np.array] = None,
        **kwargs,
    ) -> "FittableDataTransformer":
        """Fits transformer to a (sequence of) `TimeSeries` by calling the user-implemented `ts_fit` method.

        The fitted parameters returned by `ts_fit` are stored in the ``self._fitted_params`` attribute.
        If a `Sequence[TimeSeries]` is passed as the `series` data, then one of two outcomes will occur:
            1. If the `global_fit` attribute was set to `False`, then a different set of parameters will be
            individually fitted to each `TimeSeries` in the `Sequence`. In this case, this function automatically
            parallelises this fitting process over all of the multiple `TimeSeries` that have been passed.
            2. If the `global_fit` attribute was set to `True`, then all of the `TimeSeries` objects will be used
            fit a single set of parameters.

        Parameters
        ----------
        series
            (sequence of) series to fit the transformer on.
        args
            Additional positional arguments for the :func:`ts_fit` 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 transform should be fitted to.
        kwargs
            Additional keyword arguments for the :func:`ts_fit` method

        Returns
        -------
        FittableDataTransformer
            Fitted transformer.
        """
        self._fit_called = True

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

        if isinstance(series, TimeSeries):
            data = [series]
            transformer_selector = [0]
        else:
            data = series
            transformer_selector = range(len(series))

        params_iterator = self._get_params(
            transformer_selector=transformer_selector, calling_fit=True
        )
        fit_iterator = (
            zip(data, params_iterator)
            if not self._global_fit
            else zip([data], params_iterator)
        )
        n_jobs = len(data) if not self._global_fit else 1
        input_iterator = _build_tqdm_iterator(
            fit_iterator, verbose=self._verbose, desc=desc, total=n_jobs
        )

        # apply component masking to the fit method
        kwargs["mask_components"] = self._mask_components
        kwargs["mask_components_apply_only"] = True
        kwargs["component_mask"] = component_mask

        self._fitted_params = _parallel_apply(
            input_iterator, self._ts_fit, self._n_jobs, args, kwargs
        )
        return self
Fits transformer to a (sequence of) `TimeSeries` by calling the user-implemented `ts_fit` method.

        The fitted parameters returned by `ts_fit` are stored in the ``self._fitted_params`` attribute.
        If a `Sequence[TimeSeries]` is passed as the `series` data, then one of two outcomes will occur:
            1. If the `global_fit` attribute was set to `False`, then a different set of parameters will be
            individually fitted to each `TimeSeries` in the `Sequence`. In this case, this function automatically
            parallelises this fitting process over all of the multiple `TimeSeries` that have been passed.
            2. If the `global_fit` attribute was set to `True`, then all of the `TimeSeries` objects will be used
            fit a single set of parameters.

        Parameters
        ----------
        series
            (sequence of) series to fit the transformer on.
        args
            Additional positional arguments for the :func:`ts_fit` 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 transform should be fitted to.
        kwargs
            Additional keyword arguments for the :func:`ts_fit` method

        Returns
        -------
        FittableDataTransformer
            Fitted transformer.
        
darts/dataprocessing/transformers/fittable_data_transformer.py