code: def test_global_metric():
      import lenskit.crossfold as xf
      import lenskit.batch as batch
      from lenskit.algorithms.bias import Bias
  
      train, test = next(
          xf.sample_users(
              lktu.ml_test.ratings, 1, 200, xf.SampleFrac(0.5)
          )
      )
      algo = Bias()
      algo.fit(train)
  
      preds = batch.predict(algo, test)
  
      rmse = pm.global_metric(preds)
      assert rmse == pm.rmse(preds.prediction, preds.rating)
  
      mae = pm.global_metric(preds, metric=pm.mae)
      assert mae == pm.mae(preds.prediction, preds.rating)
  
imports: import numpy
  import pandas
  import os.path
  from pytest import approx, raises, mark, skip
  import lenskit.metrics.predict
  import lenskit.util.test
label_desc: Use image node_id 18 for calling a global function with example usage: test_global_metric() without return types