code: def check_datetime_variables_assignment(estimator):
      """
      Checks that transformers that work with datetime variables, correctly set
      the values for the attributes `variables` and `variables_`.
  
      The first attribute can take a string, an integer, a list of strings or integers or
      None. The second attribute can take a list of string or integers.
  
      For this check to run, the transformer needs the tag 'variables' set to
      'datetime'.
      """
  
      # toy df
      X, y = test_df(datetime=True)
  
      # input variables to test
      _input_vars_ls = ["date1", ["date2"], ["date1", "date2"], None]
  
      # the estimator
      transformer = clone(estimator)
  
      for input_vars in _input_vars_ls:
          # set the different input var examples
          transformer.set_params(variables=input_vars)
  
          # before fitting
          if input_vars is not None:
              assert transformer.variables == input_vars
          else:
              assert transformer.variables is None
  
          # fit
          transformer.fit(X, y)
  
          if input_vars is not None:
              assert transformer.variables == input_vars
  
              if isinstance(input_vars, list):
                  assert transformer.variables_ == input_vars
              else:
                  assert transformer.variables_ == [input_vars]
          else:
              assert transformer.variables is None
              assert transformer.variables_ == ["date1", "date2"]
  
      # test raises error if uses passes numerical variable
      transformer.set_params(variables=["var_1", "date1"])
      with pytest.raises(TypeError):
          transformer.fit(X, y)
  
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_datetime_variables_assignment(estimator) without return types