code: def test_prefit():
      # Test all possible combinations of the prefit parameter.
  
      # Passing a prefit parameter with the selected model
      # and fitting a unfit model with prefit=False should give same results.
      clf = SGDClassifier(
          alpha=0.1, max_iter=10, shuffle=True, random_state=0, tol=None
      )
      model = SelectFromModel(clf)
      model.fit(data, y)
      X_transform = model.transform(data)
      clf.fit(data, y)
      model = SelectFromModel(clf, prefit=True)
      assert_array_almost_equal(model.transform(data), X_transform)
      model.fit(data, y)
      assert model.estimator_ is not clf
  
      # Check that the model is rewritten if prefit=False and a fitted model is
      # passed
      model = SelectFromModel(clf, prefit=False)
      model.fit(data, y)
      assert_array_almost_equal(model.transform(data), X_transform)
  
      # Check that passing an unfitted estimator with `prefit=True` raises a
      # `ValueError`
      clf = SGDClassifier(
          alpha=0.1, max_iter=10, shuffle=True, random_state=0, tol=None
      )
      model = SelectFromModel(clf, prefit=True)
      err_msg = "When `prefit=True`, `estimator` is expected to be a fitted estimator."
      with pytest.raises(NotFittedError, match=err_msg):
          model.fit(data, y)
      with pytest.raises(NotFittedError, match=err_msg):
          model.partial_fit(data, y)
      with pytest.raises(NotFittedError, match=err_msg):
          model.transform(data)
  
      # Check that the internal parameters of prefitted model are not changed
      # when calling `fit` or `partial_fit` with `prefit=True`
      clf = SGDClassifier(
          alpha=0.1, max_iter=10, shuffle=True, tol=None
      ).fit(data, y)
      model = SelectFromModel(clf, prefit=True)
      model.fit(data, y)
      assert_allclose(model.estimator_.coef_, clf.coef_)
      model.partial_fit(data, y)
      assert_allclose(model.estimator_.coef_, clf.coef_)
  
imports: import re
  import warnings
  from unittest.mock import Mock
  import numpy
  import pytest
  from sklearn import datasets
  from sklearn.base import BaseEstimator
  from sklearn.cross_decomposition import CCA, PLSCanonical, PLSRegression
  from sklearn.datasets import make_friedman1
  from sklearn.decomposition import PCA
  from sklearn.ensemble import HistGradientBoostingClassifier, RandomForestClassifier
  from sklearn.exceptions import NotFittedError
  from sklearn.feature_selection import SelectFromModel
  from sklearn.linear_model import ElasticNet, ElasticNetCV, Lasso, LassoCV, LogisticRegression, PassiveAggressiveClassifier, SGDClassifier
  from sklearn.pipeline import make_pipeline
  from sklearn.svm import LinearSVC
  from sklearn.utils._testing import MinimalClassifier, assert_allclose, assert_array_almost_equal, assert_array_equal, skip_if_32bit
label_desc: Use image node_id 17 for calling a global function with example usage: test_prefit() without return types