code: def _r2_score_eval_fn(
      predictions, targets=None, metrics=None, sample_weight=None
  ):
      if targets is not None and len(targets) != 0:
          from sklearn.metrics import r2_score
  
          r2 = r2_score(
              targets, predictions, sample_weight=sample_weight
          )
          return MetricValue(aggregate_results={"r2_score": r2})
  
imports: import functools
  import logging
  import os
  import numpy
  from mlflow.metrics.base import MetricValue, standard_aggregations
label_desc: Use image node_id 17 for calling a global function with example usage: _r2_score_eval_fn(predictions, targets, metrics, sample_weight) and returns: MetricValue