code: def test_constant_target():
      """Check for a near constant target that a value of 0 is returned."""
      y_true = torch.tensor(
          [-5.1608, -5.1609, -5.1608, -5.1608, -5.1608, -5.1608]
      )
      y_pred = torch.tensor(
          [-3.9865, -5.4648, -5.0238, -4.3899, -5.6672, -4.7336]
      )
      score = r2_score(preds=y_pred, target=y_true)
      assert score == 0
  
imports: from functools import partial
  import pytest
  import torch
  from sklearn.metrics import r2_score
  from torchmetrics.functional import r2_score
  from torchmetrics.regression import R2Score
  from unittests import BATCH_SIZE, NUM_BATCHES, _Input
  from unittests.helpers import seed_all
  from unittests.helpers.testers import MetricTester
label_desc: Use image node_id 7 for calling a global function with example usage: test_constant_target() without return types