code: def test_unmasked_computation(self, device: str):
      spearman_correlation = SpearmanCorrelation()
      batch_size = 10
      num_labels = 10
      predictions1 = torch.randn(batch_size, num_labels, device=device)
      labels1 = 0.5 * predictions1 + torch.randn(
          batch_size, num_labels, device=device
      )
  
      predictions2 = torch.randn(1, device=device).repeat(num_labels)
      predictions2 = predictions2.unsqueeze(0).expand(batch_size, -1)
      labels2 = torch.randn(1, device=device).expand(num_labels)
      labels2 = 0.5 * predictions2 + labels2.unsqueeze(0).expand(
          batch_size, -1
      )
  
      # in most cases, the data is constructed like predictions_1, the data of such a batch different.
      # but in a few cases, for example, predictions_2, the data of such a batch is exactly the same.
      predictions_labels_ = [
          (predictions1, labels1),
          (predictions2, labels2),
      ]
  
      for predictions, labels in predictions_labels_:
          spearman_correlation.reset()
          spearman_correlation(predictions, labels)
          assert_allclose(
              spearman_formula(
                  predictions.reshape(-1), labels.reshape(-1)
              ),
              spearman_correlation.get_metric(),
          )
  
file_path: allennlp/tests/training/metrics/spearman_correlation_test.py
imports: import math
  import pytest
  import torch
  from torch.testing import assert_allclose
  from allennlp.common.testing import AllenNlpTestCase, multi_device, global_distributed_metric, run_distributed_test
  from allennlp.training.metrics import SpearmanCorrelation
label_desc: Use image node_id 1 for calling the SpearmanCorrelationTest obj's underlying member method code with example usage: obj.test_unmasked_computation(device) without return types