code: def metalearner_property_test():
      train = h2o.import_file(
          pyunit_utils.locate("smalldata/iris/iris_train.csv")
      )
      test = h2o.import_file(
          pyunit_utils.locate("smalldata/iris/iris_test.csv")
      )
      x = train.columns
      y = "species"
      x.remove(y)
  
      nfolds = 2
      gbm = H2OGradientBoostingEstimator(
          nfolds=nfolds,
          fold_assignment="Modulo",
          keep_cross_validation_predictions=True,
      )
      gbm.train(x=x, y=y, training_frame=train)
      rf = H2ORandomForestEstimator(
          nfolds=nfolds,
          fold_assignment="Modulo",
          keep_cross_validation_predictions=True,
      )
      rf.train(x=x, y=y, training_frame=train)
      se = H2OStackedEnsembleEstimator(
          training_frame=train,
          validation_frame=test,
          base_models=[gbm.model_id, rf.model_id],
      )
      se.train(x=x, y=y, training_frame=train)
  
      old_way_retrieved_metalearner = h2o.get_model(
          se.metalearner().model_id
      )
  
      # Test backward compatibility
      assert (
          se.metalearner().model_id
          == old_way_retrieved_metalearner.model_id
      )
      # Test we get the same metalearner as we used to get
      assert (
          old_way_retrieved_metalearner.model_id
          == se.metalearner().model_id
      )
  
      # Check we emit deprecation warning
      for v in sys.modules.values():
          if getattr(v, "__warningregistry__", None):
              v.__warningregistry__ = {}
      with warnings.catch_warnings(record=True) as ws:
          # Get all DeprecationWarnings
          warnings.simplefilter("always", DeprecationWarning)
          # Trigger a warning.
          _ = se.metalearner()["name"]
          # Assert that we get the deprecation warning
          assert any(
              (
                  issubclass(w.category, DeprecationWarning)
                  and "metalearner()['name']" in str(w.message)
                  for w in ws
              )
          )
  
file_path: h2o-3/h2o-py/tests/testdir_algos/stackedensemble/pyunit_stackedensemble_metalearner.py
imports: import sys
  import warnings
  import h2o
  from h2o.estimators.random_forest import H2ORandomForestEstimator
  from h2o.estimators.gbm import H2OGradientBoostingEstimator
  from h2o.estimators.stackedensemble import H2OStackedEnsembleEstimator
  from tests import pyunit_utils
label_desc: Use image node_id 2 for calling a global function with example usage: metalearner_property_test() without return types