code: def check_fit_idempotent(name, estimator_orig):
      # Check that est.fit(X) is the same as est.fit(X).fit(X). Ideally we would
      # check that the estimated parameters during training (e.g. coefs_) are
      # the same, but having a universal comparison function for those
      # attributes is difficult and full of edge cases. So instead we check that
      # predict(), predict_proba(), decision_function() and transform() return
      # the same results.
  
      check_methods = [
          "predict",
          "transform",
          "decision_function",
          "predict_proba",
      ]
      rng = np.random.RandomState(0)
  
      if estimator_orig._get_tags()["non_deterministic"]:
          msg = name + " is non deterministic"
          raise SkipTest(msg)
  
      estimator = clone(estimator_orig)
      set_random_state(estimator)
      if "warm_start" in estimator.get_params().keys():
          estimator.set_params(warm_start=False)
  
      n_samples = 100
      X, _ = _create_small_ts_dataset()
      X = X.reshape((X.shape[0], X.shape[1]))
      X = pairwise_estimator_convert_X(X, estimator)
      if is_regressor(estimator_orig):
          y = rng.normal(size=n_samples)
      else:
          y = rng.randint(low=0, high=2, size=n_samples)
  
      train, test = next(
          ShuffleSplit(test_size=0.2, random_state=rng).split(X)
      )
      X_train, y_train = _safe_split(estimator, X, y, train)
      X_test, y_test = _safe_split(estimator, X, y, test, train)
  
      # Fit for the first time
      estimator.fit(X_train, y_train)
  
      result = {
          method: getattr(estimator, method)(X_test)
          for method in check_methods
          if hasattr(estimator, method)
      }
  
      # Fit again
      set_random_state(estimator)
      estimator.fit(X_train, y_train)
  
      for method in check_methods:
          if hasattr(estimator, method):
              new_result = getattr(estimator, method)(X_test)
              if np.issubdtype(new_result.dtype, np.floating):
                  tol = 2 * np.finfo(new_result.dtype).eps
              else:
                  tol = 2 * np.finfo(np.float64).eps
              assert_allclose_dense_sparse(
                  result[method],
                  new_result,
                  atol=max(tol, 1e-9),
                  rtol=max(tol, 1e-7),
                  err_msg="Idempotency check failed for method {}".format(
                      method
                  ),
              )
  
imports: from tslearn.generators import random_walk_blobs
  from tslearn.preprocessing import TimeSeriesScalerMeanVariance
  import sklearn
  import warnings
  from sklearn.base import clone
  from sklearn.base import is_classifier, is_outlier_detector, is_regressor
  from sklearn.base import ClusterMixin
  from sklearn.exceptions import DataConversionWarning
  from sklearn.datasets import make_blobs
  from sklearn.metrics.pairwise import rbf_kernel, linear_kernel, pairwise_distances
  from sklearn.utils import shuffle
  from sklearn.utils.estimator_checks import check_classifiers_predictions, check_fit2d_1sample, check_fit2d_1feature, check_fit1d, check_get_params_invariance, check_set_params, check_dict_unchanged, check_dont_overwrite_parameters, check_estimators_data_not_an_array, check_fit2d_predict1d, check_methods_subset_invariance, check_regressors_int
  from sklearn.exceptions import SkipTestWarning
  from sklearn.utils.estimator_checks import _yield_classifier_checks, _yield_regressor_checks, _yield_transformer_checks, _yield_clustering_checks, _yield_outliers_checks, _is_pairwise_metric
  from sklearn.metrics import adjusted_rand_score, accuracy_score
  from sklearn.model_selection import ShuffleSplit
  from sklearn.model_selection._validation import _safe_split
  from sklearn.pipeline import make_pipeline
  from tslearn.clustering import TimeSeriesKMeans
  import warnings
  import numpy
label_desc: Use image node_id 8 for calling a global function with example usage: check_fit_idempotent(name, estimator_orig) without return types