code: def test_automl_stops_after_max_models():
      print("Check that automl gets interrupted after `max_models`")
      ds = import_dataset()
      max_models = 5
      aml = H2OAutoML(
          project_name="py_aml_max_models",
          seed=1,
          max_models=max_models,
      )
      aml.train(y=ds.target, training_frame=ds.train)
  
      base_models = get_partitioned_model_names(aml.leaderboard).base
      assert (
          len(base_models) == max_models
      ), "obtained {} base models when {} are expected".format(
          len(base_models), max_models
      )
  
file_path: h2o-3/h2o-py/tests/testdir_algos/automl/pyunit_automl_early_stopping.py
imports: import sys, os
  from h2o.exceptions import H2OJobCancelled
  from h2o.automl import H2OAutoML
  from tests import pyunit_utils
  from _automl_utils import import_dataset, get_partitioned_model_names
label_desc: Use image node_id 3 for calling a global function with example usage: test_automl_stops_after_max_models() without return types