code: def test_r2_score():
      size = 51
      np_y_pred = np.random.rand(size)
      np_y = np.random.rand(size)
  
      m = R2Score()
      y_pred = torch.from_numpy(np_y_pred)
      y = torch.from_numpy(np_y)
  
      m.reset()
      m.update((y_pred, y))
  
      assert r2_score(np_y, np_y_pred) == pytest.approx(m.compute())
  
imports: import os
  import numpy
  import pytest
  import torch
  from sklearn.metrics import r2_score
  import ignite.distributed
  from ignite.contrib.metrics.regression import R2Score
  from ignite.engine import Engine
  from ignite.exceptions import NotComputableError
label_desc: Use image node_id 3 for calling a global function with example usage: test_r2_score() without return types