class_docstr: Compute `spearmans rank correlation coefficient`_.
  
  .. math:
      r_s = = \frac{cov(rg_x, rg_y)}{\sigma_{rg_x} * \sigma_{rg_y}}
  
  where :math:`rg_x` and :math:`rg_y` are the rank associated to the variables :math:`x` and :math:`y`.
  Spearmans correlations coefficient corresponds to the standard pearsons correlation coefficient calculated
  on the rank variables.
  
  As input to ``forward`` and ``update`` the metric accepts the following input:
  
  - ``preds`` (:class:`~torch.Tensor`): Predictions from model in float tensor with shape ``(N,d)``
  - ``target`` (:class:`~torch.Tensor`): Ground truth values in float tensor with shape ``(N,d)``
  
  As output of ``forward`` and ``compute`` the metric returns the following output:
  
  - ``spearman`` (:class:`~torch.Tensor`): A tensor with the spearman correlation(s)
  
  Args:
      num_outputs: Number of outputs in multioutput setting
      kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.
  
  Example (single output regression):
      >>> from torch import tensor
      >>> from torchmetrics.regression import SpearmanCorrCoef
      >>> target = tensor([3, -0.5, 2, 7])
      >>> preds = tensor([2.5, 0.0, 2, 8])
      >>> spearman = SpearmanCorrCoef()
      >>> spearman(preds, target)
      tensor(1.0000)
  
  Example (multi output regression):
      >>> from torchmetrics.regression import SpearmanCorrCoef
      >>> target = tensor([[3, -0.5], [2, 7]])
      >>> preds = tensor([[2.5, 0.0], [2, 8]])
      >>> spearman = SpearmanCorrCoef(num_outputs=2)
      >>> spearman(preds, target)
      tensor([1.0000, 1.0000])
code: def __init__(
      self,
      num_outputs: int = 1,
      **kwargs: Any,
  ) -> None:
      super().__init__(**kwargs)
      rank_zero_warn(
          "Metric `SpearmanCorrcoef` will save all targets and predictions in the buffer."
          " For large datasets, this may lead to large memory footprint."
      )
      if not isinstance(num_outputs, int) and num_outputs < 1:
          raise ValueError(
              "Expected argument `num_outputs` to be an int larger than 0, but got {num_outputs}"
          )
      self.num_outputs = num_outputs
  
      self.add_state("preds", default=[], dist_reduce_fx="cat")
      self.add_state("target", default=[], dist_reduce_fx="cat")
  
file_path: torchmetrics/src/torchmetrics/regression/spearman.py
imports: from typing import Any, List, Optional, Sequence, Union
  from torch import Tensor
  from torchmetrics.functional.regression.spearman import _spearman_corrcoef_compute, _spearman_corrcoef_update
  from torchmetrics.metric import Metric
  from torchmetrics.utilities import rank_zero_warn
  from torchmetrics.utilities.data import dim_zero_cat
  from torchmetrics.utilities.imports import _MATPLOTLIB_AVAILABLE
  from torchmetrics.utilities.plot import _AX_TYPE, _PLOT_OUT_TYPE
label_desc: Use image node_id 1 to create a new SpearmanCorrCoef object from inherited base classes: Metric with example: obj = SpearmanCorrCoef(num_outputs)