code: def grid_f2_metrics():
      gbm_grid1 = train_grid()
  
      gbm_gridper_f2 = gbm_grid1.get_grid(sort_by="f2", decreasing=True)
      print(gbm_gridper_f2)
      sorted_metric_table_f2 = gbm_gridper_f2.sorted_metric_table()
  
      # Lets compare values grid was sorted with and metrics from each model in the grid
      print("Model 0:")
      best_gbm_f2 = gbm_gridper_f2.models[0]
      model0_f2_valid = best_gbm_f2.F2(valid=True)
      print(model0_f2_valid)
  
      errorMsg = "Expected that metric value from sorted_metric_table is equal to corresponding metric for the model"
      assert float(model0_f2_valid[0][1]) == float(
          sorted_metric_table_f2["f2"][0]
      ), errorMsg
  
      print("Model 1:")
      best_gbm_f2_1 = gbm_gridper_f2.models[1]
      model1_f2_valid = best_gbm_f2_1.F2(valid=True)
      print(model1_f2_valid)
      assert float(model1_f2_valid[0][1]) == float(
          sorted_metric_table_f2["f2"][1]
      ), errorMsg
  
      print("Model 2:")
      best_gbm_f2_2 = gbm_gridper_f2.models[2]
      model2_f2_valid = best_gbm_f2_2.F2(valid=True)
      print(model2_f2_valid)
      assert float(model2_f2_valid[0][1]) == float(
          sorted_metric_table_f2["f2"][2]
      ), errorMsg
  
imports: import sys
  import h2o
  from tests import pyunit_utils
  from h2o.estimators.gbm import H2OGradientBoostingEstimator
  from h2o.grid.grid_search import H2OGridSearch
label_desc: Use image node_id 2 for calling a global function with example usage: grid_f2_metrics() without return types