code: def test_r2_score():
      """Test that R^2 metric passes basic sanity tests"""
      np.random.seed(123)
      n_samples = 10
      y_true = np.random.rand(
          n_samples,
      )
      y_pred = np.random.rand(
          n_samples,
      )
      regression_metric = dc.metrics.Metric(
          dc.metrics.r2_score, n_tasks=1
      )
      assert np.isclose(
          dc.metrics.r2_score(y_true, y_pred),
          regression_metric.compute_metric(y_true, y_pred),
      )
  
file_path: deepchem/deepchem/metrics/tests/test_metrics.py
imports: import numpy
  import deepchem
label_desc: Use image node_id 4 for calling a global function with example usage: test_r2_score() without return types