code: def check_raises_error_if_only_1_variable(estimator):
      """For feature selection transformers.
  
      Checks that the transformer has 2 or more
      variables to select from during the search procedure.
      """
      X, y = test_df()
      estimator = clone(estimator)
      sel = estimator.set_params(
          variables=["var_1"],
          confirm_variables=False,
      )
  
      msg = (
          "The selector needs at least 2 or more variables to select from. "
          "Got only 1 variable: ['var_1']."
      )
      with pytest.raises(ValueError) as record:
          sel.fit(X, y)
  
      assert str(record.value) == msg
  
imports: import pytest
  from sklearn import clone
  from tests.estimator_checks.dataframe_for_checks import test_df
label_desc: Use image node_id 4 for calling a global function with example usage: check_raises_error_if_only_1_variable(estimator) without return types