code: def test_raises_error_when_df_has_nan(df_enc, df_na, estimator):
      transformer = clone(estimator)
  
      X, y = test_df(categorical=True)
      X_na = X.copy()
  
      X_na.loc[0, "var_1"] = np.nan
  
      if transformer.__class__.__name__ != "TargetMeanRegressor":
          # Raise error when dataset contains na, fit method
          with pytest.raises(ValueError):
              transformer.fit(X_na, y)
  
          transformer.fit(X, y)
          if hasattr(transformer, "_predict"):
              with pytest.raises(ValueError):
                  transformer._predict(X_na)
          else:
              with pytest.raises(ValueError):
                  transformer.predict(X_na)
              with pytest.raises(ValueError):
                  transformer.predict_proba(X_na)
              with pytest.raises(ValueError):
                  transformer.predict_log_proba(X_na)
  
      else:
          y = X["var_10"]
          with pytest.raises(ValueError):
              transformer.fit(X_na, y)
  
          transformer.fit(X, y)
          with pytest.raises(ValueError):
              transformer.predict(X_na)
  
imports: import numpy
  import pandas
  import pytest
  from sklearn.base import clone
  from sklearn.exceptions import NotFittedError
  from sklearn.utils.estimator_checks import check_estimator
  from feature_engine._prediction.base_predictor import BaseTargetMeanEstimator
  from feature_engine._prediction.target_mean_classifier import TargetMeanClassifier
  from feature_engine._prediction.target_mean_regressor import TargetMeanRegressor
  from feature_engine.discretisation import EqualFrequencyDiscretiser, EqualWidthDiscretiser
  from feature_engine.encoding import MeanEncoder
  from tests.estimator_checks.dataframe_for_checks import test_df
  from tests.estimator_checks.fit_functionality_checks import check_error_if_y_not_passed
label_desc: Use image node_id 9 for calling a global function with example usage: test_raises_error_when_df_has_nan(df_enc, df_na, estimator) without return types