code: def gbm_residual_deviance():
      cars = h2o.import_file(
          path=pyunit_utils.locate(
              "smalldata/airlines/AirlinesTest.csv.zip"
          )
      )
      gbm = H2OGradientBoostingEstimator()
      gbm.train(
          x=list(range(9)),
          y=9,
          training_frame=cars,
          validation_frame=cars,
      )
  
      # set valid/xval = True if you have provided a validation dataset/enabled cross-validation.
      gbm_mrd = gbm.mean_residual_deviance(
          train=True, valid=False, xval=False
      )
      print("Training mean residual deviance is {0}".format(gbm_mrd))
  
      # if you want to see the scoring history of validation, look at field training_deviance of scoring history
      mean_residual_deviance_history = extract_scoring_history_field(
          gbm, "training_deviance"
      )
      print(
          "History of training mean residual deviance during training is {0}".format(
              mean_residual_deviance_history
          )
      )
  
      assert (
          abs(mean_residual_deviance_history[-1] - gbm_mrd) < 1e-12
      ), "mean_residual_deviance function is not working."
  
imports: import sys
  import h2o
  from tests import pyunit_utils
  from h2o.estimators.gbm import H2OGradientBoostingEstimator
label_desc: Use image node_id 1 for calling a global function with example usage: gbm_residual_deviance() without return types