code: def test_custom_metric_early_stopping():
      (ftrain, fvalid, _) = dataset_prostate()
      model_expected = H2OGradientBoostingEstimator(
          model_id="prostate",
          ntrees=1000,
          max_depth=5,
          score_each_iteration=True,
          stopping_metric="mae",
          stopping_tolerance=0.1,
          stopping_rounds=3,
          seed=123,
      )
      model_expected.train(
          y="AGE",
          x=ftrain.names,
          training_frame=ftrain,
          validation_frame=fvalid,
      )
  
      model_actual = H2OGradientBoostingEstimator(
          model_id="prostate",
          ntrees=1000,
          max_depth=5,
          score_each_iteration=True,
          custom_metric_func=custom_mae_mm(),
          stopping_metric="custom",
          stopping_tolerance=0.1,
          stopping_rounds=3,
          seed=123,
      )
      model_actual.train(
          y="AGE",
          x=ftrain.names,
          training_frame=ftrain,
          validation_frame=fvalid,
      )
  
      assert_same_scoring_history(
          model_actual,
          model_expected,
          "training_custom",
          "training_mae",
      )
  
imports: import sys
  import h2o
  from tests import pyunit_utils
  from tests.pyunit_utils import CustomMaeFunc, dataset_prostate
  from h2o.estimators.gbm import H2OGradientBoostingEstimator
label_desc: Use image node_id 3 for calling a global function with example usage: test_custom_metric_early_stopping() without return types