code: def test_dont_overwrite_parameters(
      estimator, build_dataset, with_preprocessor
  ):
      # Adapted from scikit-learn
      # check that fit method only changes or sets private attributes
      input_data, labels, preprocessor, _ = build_dataset(
          with_preprocessor
      )
      estimator = clone(estimator)
      estimator.set_params(preprocessor=preprocessor)
      if hasattr(estimator, "n_components"):
          estimator.n_components = 1
      dict_before_fit = estimator.__dict__.copy()
  
      estimator.fit(*remove_y(estimator, input_data, labels))
      dict_after_fit = estimator.__dict__
  
      public_keys_after_fit = [
          key
          for key in dict_after_fit.keys()
          if is_public_parameter(key)
      ]
  
      attrs_added_by_fit = [
          key
          for key in public_keys_after_fit
          if key not in dict_before_fit.keys()
      ]
  
      # check that fit doesn't add any public attribute
      assert not attrs_added_by_fit, (
          "Estimator adds public attribute(s) during"
          " the fit method."
          " Estimators are only allowed to add private "
          "attributes"
          " either started with _ or ended"
          " with _ but %s added" % ", ".join(attrs_added_by_fit)
      )
  
      # check that fit doesn't change any public attribute
      attrs_changed_by_fit = [
          key
          for key in public_keys_after_fit
          if (dict_before_fit[key] is not dict_after_fit[key])
      ]
  
      assert not attrs_changed_by_fit, (
          "Estimator changes public attribute(s) during"
          " the fit method. Estimators are only allowed"
          " to change attributes started"
          " or ended with _, but"
          " %s changed" % ", ".join(attrs_changed_by_fit)
      )
  
imports: import pytest
  import unittest
  from sklearn.utils.estimator_checks import check_estimator
  from sklearn.base import TransformerMixin
  from sklearn.pipeline import make_pipeline
  from sklearn.utils import check_random_state
  from metric_learn.sklearn_shims import assert_allclose_dense_sparse, set_random_state, _get_args, is_public_parameter, get_scorer
  from metric_learn import Covariance, LFDA, LMNN, MLKR, NCA, ITML_Supervised, LSML_Supervised, MMC_Supervised, RCA_Supervised, SDML_Supervised, SCML_Supervised
  from sklearn import clone
  import numpy
  from sklearn.model_selection import cross_val_score, cross_val_predict, train_test_split, KFold
  from test.test_utils import metric_learners, ids_metric_learners, mock_preprocessor, tuples_learners, ids_tuples_learners, pairs_learners, ids_pairs_learners, remove_y, metric_learners_pipeline, ids_metric_learners_pipeline
label_desc: Use image node_id 14 for calling a global function with example usage: test_dont_overwrite_parameters(estimator, build_dataset, with_preprocessor) without return types