code: def test_error_on_different_shape():
      """Test that error is raised when the preds and target shapes are not what is expected of the metric."""
      metric = SpearmanCorrCoef(num_outputs=1)
      with pytest.raises(
          TypeError,
          match="Expected `preds` and `target` both to be floating point tensors.*",
      ):
          metric(torch.randint(5, (100,)), torch.randn(100))
  
      with pytest.raises(
          RuntimeError,
          match="Predictions and targets are expected to have the same shape",
      ):
          metric(torch.randn(100), torch.randn(50))
  
      metric = SpearmanCorrCoef(num_outputs=5)
      with pytest.raises(
          ValueError,
          match="Expected both predictions and target to be either 1- or 2-dimensional.*",
      ):
          metric(torch.randn(100, 2, 5), torch.randn(100, 2, 5))
  
      metric = SpearmanCorrCoef(num_outputs=2)
      with pytest.raises(
          ValueError,
          match="Expected argument `num_outputs` to match the second dimension of input.*",
      ):
          metric(torch.randn(100, 5), torch.randn(100, 5))
  
file_path: torchmetrics/tests/unittests/regression/test_spearman.py
imports: from functools import partial
  import pytest
  import torch
  from scipy.stats import rankdata, spearmanr
  from torchmetrics.functional.regression.spearman import _rank_data, spearman_corrcoef
  from torchmetrics.regression.spearman import SpearmanCorrCoef
  from torchmetrics.utilities.imports import _TORCH_GREATER_EQUAL_2_1
  from unittests import BATCH_SIZE, EXTRA_DIM, NUM_BATCHES, _Input
  from unittests.helpers import seed_all
  from unittests.helpers.testers import MetricTester
label_desc: Use image node_id 3 for calling a global function with example usage: test_error_on_different_shape() without return types