code: def check_confirm_variables(estimator):
      """
      Only for transformers with a parameter `confirm_variables`in init.
  
      At the moment, this test applies to variable selection transformers. The idea is
      to corroborate if the variables entered by the user are present in the dataframe
      before doing the selection, when the parameter is True.
      """
      X, y = test_df()
      Xs = X.drop(labels=["var_10", "var_11"], axis=1)
  
      # original variables in X
      all_vars = ["var_" + str(i) for i in range(12)]
  
      estimator = clone(estimator)
  
      sel = estimator.set_params(
          variables=all_vars,
          confirm_variables=False,
      )
      sel.fit(X, y)
      assert sel.variables_ == all_vars
  
      sel = estimator.set_params(
          variables=all_vars,
          confirm_variables=True,
      )
      sel.fit(Xs, y)
      assert sel.variables_ == ["var_" + str(i) for i in range(10)]
  
      sel = estimator.set_params(
          variables=all_vars,
          confirm_variables=False,
      )
      with pytest.raises(KeyError):
          sel.fit(Xs, y)
  
      # When variables is None.
      sel = estimator.set_params(
          variables=None,
          confirm_variables=True,
      )
      sel.fit(X, y)
      assert sel.variables_ == all_vars
  
      sel.fit(Xs, y)
      assert sel.variables_ == ["var_" + str(i) for i in range(10)]
  
imports: import pytest
  from sklearn import clone
  from tests.estimator_checks.dataframe_for_checks import test_df
label_desc: Use image node_id 3 for calling a global function with example usage: check_confirm_variables(estimator) without return types