def test_global_fitting(self):
        """
        Tests that invertible time-averaged mean subtraction transformation
        behaves correctly when `global_fit = False` and when `global_fit = True`.
        """

        series_1 = TimeSeries.from_values(np.ones((3, 2, 1)))
        series_2 = TimeSeries.from_values(2 * np.ones((3, 2, 1)))

        # Local fitting - subtracting mean of each series from itself should return
        # zero-valued series:
        transformer = self.DataTransformerMock(global_fit=False)
        transformed_1, transformed_2 = transformer.fit_transform([series_1, series_2])
        assert transformed_1 == TimeSeries.from_values(np.zeros((3, 2, 1)))
        assert transformed_2 == TimeSeries.from_values(np.zeros((3, 2, 1)))
        # Inverting transform should return input:
        untransformed_1, untransformed_2 = transformer.inverse_transform([
            transformed_1,
            transformed_2,
        ])
        assert untransformed_1 == series_1
        assert untransformed_2 == series_2

        # Global fitting - mean of `series_1` and `series_2` should be `1.5`, so
        # `series_1` values should be transformed to `-0.5` and `series_2` values
        # should be transformed to `1.5`:
        transformer = self.DataTransformerMock(global_fit=True)
        transformed_1, transformed_2 = transformer.fit_transform([series_1, series_2])
        assert transformed_1 == TimeSeries.from_values(-0.5 * np.ones((3, 2, 1)))
        assert transformed_2 == TimeSeries.from_values(0.5 * np.ones((3, 2, 1)))
        # Inverting transform should return input:
        untransformed_1, untransformed_2 = transformer.inverse_transform([
            transformed_1,
            transformed_2,
        ])
        assert untransformed_1 == series_1
        assert untransformed_2 == series_2

        Tests that invertible time-averaged mean subtraction transformation
        behaves correctly when `global_fit = False` and when `global_fit = True`.
        
darts/tests/dataprocessing/transformers/test_invertible_fittable_data_transformer.py