code: def check_takes_cv_constructor(estimator):
      """
      Only for transformers with a parameter `cv`in init.
  
      For those transformers that implement cross-validation, checks that all
      sklearn cross-validation constructors can be used with the transformer.
  
      This checks corroborates that the attributes learned during fit() are indeed
      learned.
      """
      from sklearn.model_selection import KFold, StratifiedKFold
  
      X, y = test_df(categorical=True)
  
      estimator = clone(estimator)
  
      cv_constructor_ls = [
          KFold(n_splits=3),
          StratifiedKFold(n_splits=3),
          None,
      ]
  
      for cv_constructor in cv_constructor_ls:
          sel = estimator.set_params(cv=cv_constructor)
          sel.fit(X, y)
          Xtransformed = sel.transform(X)
  
          # test fit attrs
          if hasattr(sel, "initial_model_performance_"):
              assert isinstance(
                  sel.initial_model_performance_, (int, float)
              )
  
          if hasattr(sel, "features_to_drop_"):
              assert isinstance(sel.features_to_drop_, list)
              assert all(
                  [x for x in sel.features_to_drop_ if x in X.columns]
              )
              assert len(sel.features_to_drop_) < X.shape[1]
  
              assert not Xtransformed.empty
              assert all(
                  [
                      x
                      for x in Xtransformed.columns
                      if x not in sel.features_to_drop_
                  ]
              )
  
          if hasattr(sel, "performance_drifts_"):
              assert isinstance(sel.performance_drifts_, dict)
              assert all(
                  [
                      x
                      for x in X.columns
                      if x in sel.performance_drifts_.keys()
                  ]
              )
              assert all(
                  [
                      isinstance(
                          sel.performance_drifts_[var], (int, float)
                      )
                      for var in sel.performance_drifts_.keys()
                  ]
              )
  
          if hasattr(sel, "feature_performance_"):
              assert isinstance(sel.feature_performance_, dict)
              assert all(
                  [
                      x
                      for x in X.columns
                      if x in sel.feature_performance_.keys()
                  ]
              )
              assert all(
                  [
                      isinstance(
                          sel.feature_performance_[var], (int, float)
                      )
                      for var in sel.feature_performance_.keys()
                  ]
              )
  
          if hasattr(sel, "scores_dict_"):
              assert isinstance(sel.scores_dict_, dict)
              assert all(
                  [x for x in X.columns if x in sel.scores_dict_.keys()]
              )
              assert all(
                  [
                      isinstance(sel.scores_dict_[var], (int, float))
                      for var in sel.scores_dict_.keys()
                  ]
              )
  
imports: import pytest
  from sklearn import clone
  from tests.estimator_checks.dataframe_for_checks import test_df
label_desc: Use image node_id 1 for calling a global function with example usage: check_takes_cv_constructor(estimator) without return types