code: def user_metric(
      predictions, *, score_column="prediction", metric=rmse, **kwargs
  ):
      """
      Compute a mean per-user prediction accuracy metric for a set of predictions.
  
      Args:
          predictions(pandas.DataFrame):
              Data frame containing the predictions.  Must have a column ``rating``
              containing ground truth and a score column with rating predictions,
              along with a ``'user'`` column with user IDs.
          score_column(str):
              The name of the score column (defaults to ``'prediction'``).
          metric(function):
              A metric function of two parameters (prediction and truth).  Defaults
              to :py:func:`rmse`.
  
      Returns:
          float: The mean of the per-user value of the metric.
      """
  
      def score(df):
          return metric(df[score_column], df["rating"])
  
      u_scores = predictions.groupby("user").apply(score)
      return u_scores.mean()
  
imports: import numpy
  import pandas
label_desc: Use image node_id 5 for calling a global function with example usage: user_metric(predictions) and returns: u_scores, metric