code: def test_r2_score_single_sample():
      metric = metric_modules.R2Score(num_outputs=1)
      with metric.sync_context():
          metric.update(
              preds=torch.tensor([0.8]), target=torch.arange(1)
          )
          assert torch.isnan(metric.compute())
  
imports: import pytest
  import torch
  from ludwig.distributed import init_dist_strategy
  from ludwig.modules import metric_modules
  from ludwig.schema.features.loss.loss import BWCEWLossConfig, SigmoidCrossEntropyLossConfig, SoftmaxCrossEntropyLossConfig
label_desc: Use image node_id 6 for calling a global function with example usage: test_r2_score_single_sample() without return types