code: def test_differencer_inverse_does_not_memorize():
      """Tests that differencer inverse always computes inverse via cumsum.
  
      Test case by ilkersigirci in #3345 (simplified)
  
      Failure mode:
      previous versions "remembered" the fit data, which can lead to unexpected
      output in the case of pipelining forecasters with a Differencer, see # 3345
      """
      import numpy as np
  
      from sktime.forecasting.base import ForecastingHorizon
      from sktime.forecasting.naive import NaiveForecaster
      from sktime.split import temporal_train_test_split
      from sktime.transformations.series.difference import Differencer
  
      y = load_airline()
  
      y_train, y_test = temporal_train_test_split(y=y, test_size=30)
      fh_out = np.arange(1, len(y_test) + 1)
      fh_ins = ForecastingHorizon(y_train.index, is_relative=False)[1:]
  
      pipe = Differencer() * NaiveForecaster()
  
      pipe.fit(y=y_train)
      pipe_ins = pipe.predict(fh=fh_ins)
      pipe.predict(fh=fh_out)
  
      naive_model = NaiveForecaster()
      naive_model.fit(y=y_train)
      model_ins = naive_model.predict(fh=fh_ins)
      naive_model.predict(fh=fh_out)
  
      # pipe output should not be similar to train input
      assert not np.allclose(
          y_train[1:].to_numpy(), pipe_ins.to_numpy()
      )
  
      # pipe output should be similar to model output
      assert np.allclose(pipe_ins.to_numpy(), model_ins.to_numpy())
      # (first element can be different)
  
      # model output should not be similar to train input
      assert not np.allclose(
          y_train[1:].to_numpy(), model_ins.to_numpy()
      )
  
file_path: sktime/sktime/transformations/series/tests/test_differencer.py
imports: import numpy
  import pandas
  import pytest
  from sktime.datasets import load_airline
  from sktime.transformations.series.difference import Differencer
  from sktime.utils._testing.estimator_checks import _assert_array_almost_equal
  from sktime.utils.validation._dependencies import _check_soft_dependencies
label_desc: Use image node_id 7 for calling a global function with example usage: test_differencer_inverse_does_not_memorize() without return types