code: def test_ranking(preds, target):
      """Test that ranking function works as expected."""
      for p, t in zip(preds, target):
          scipy_ranking = [rankdata(p.numpy()), rankdata(t.numpy())]
          tm_ranking = [_rank_data(p), _rank_data(t)]
          assert (torch.tensor(scipy_ranking[0]) == tm_ranking[0]).all()
          assert (torch.tensor(scipy_ranking[1]) == tm_ranking[1]).all()
  
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 1 for calling a global function with example usage: test_ranking(preds, target) without return types