code: def spearmanr(
      x, y=None, use_ties=True, axis=None, nan_policy="propagate"
  ):
      """
      Calculates a Spearman rank-order correlation coefficient and the p-value
      to test for non-correlation.
  
      The Spearman correlation is a nonparametric measure of the linear
      relationship between two datasets. Unlike the Pearson correlation, the
      Spearman correlation does not assume that both datasets are normally
      distributed. Like other correlation coefficients, this one varies
      between -1 and +1 with 0 implying no correlation. Correlations of -1 or
      +1 imply a monotonic relationship. Positive correlations imply that
      as `x` increases, so does `y`. Negative correlations imply that as `x`
      increases, `y` decreases.
  
      Missing values are discarded pair-wise: if a value is missing in `x`, the
      corresponding value in `y` is masked.
  
      The p-value roughly indicates the probability of an uncorrelated system
      producing datasets that have a Spearman correlation at least as extreme
      as the one computed from these datasets. The p-values are not entirely
      reliable but are probably reasonable for datasets larger than 500 or so.
  
      Parameters
      ----------
      x, y : 1D or 2D array_like, y is optional
          One or two 1-D or 2-D arrays containing multiple variables and
          observations. When these are 1-D, each represents a vector of
          observations of a single variable. For the behavior in the 2-D case,
          see under ``axis``, below.
      use_ties : bool, optional
          DO NOT USE.  Does not do anything, keyword is only left in place for
          backwards compatibility reasons.
      axis : int or None, optional
          If axis=0 (default), then each column represents a variable, with
          observations in the rows. If axis=1, the relationship is transposed:
          each row represents a variable, while the columns contain observations.
          If axis=None, then both arrays will be raveled.
      nan_policy : {'propagate', 'raise', 'omit'}, optional
          Defines how to handle when input contains nan. 'propagate' returns nan,
          'raise' throws an error, 'omit' performs the calculations ignoring nan
          values. Default is 'propagate'.
  
      Returns
      -------
      correlation : float
          Spearman correlation coefficient
      pvalue : float
          2-tailed p-value.
  
      References
      ----------
      [CRCProbStat2000] section 14.7
  
      """
      if not use_ties:
          raise ValueError(
              "`use_ties=False` is not supported in SciPy >= 1.2.0"
          )
  
      # Always returns a masked array, raveled if axis=None
      x, axisout = _chk_asarray(x, axis)
      if y is not None:
          # Deal only with 2-D `x` case.
          y, _ = _chk_asarray(y, axis)
          if axisout == 0:
              x = ma.column_stack((x, y))
          else:
              x = ma.row_stack((x, y))
  
      if axisout == 1:
          # To simplify the code that follow (always use `n_obs, n_vars` shape)
          x = x.T
  
      if nan_policy == "omit":
          x = ma.masked_invalid(x)
  
      def _spearmanr_2cols(x):
          # Mask the same observations for all variables, and then drop those
          # observations (can't leave them masked, rankdata is weird).
          x = ma.mask_rowcols(x, axis=0)
          x = x[~x.mask.any(axis=1), :]
  
          m = ma.getmask(x)
          n_obs = x.shape[0]
          dof = n_obs - 2 - int(m.sum(axis=0)[0])
          if dof < 0:
              raise ValueError(
                  "The input must have at least 3 entries!"
              )
  
          # Gets the ranks and rank differences
          x_ranked = rankdata(x, axis=0)
          rs = ma.corrcoef(x_ranked, rowvar=False).data
  
          # rs can have elements equal to 1, so avoid zero division warnings
          olderr = np.seterr(divide="ignore")
          try:
              # clip the small negative values possibly caused by rounding
              # errors before taking the square root
              t = rs * np.sqrt(
                  (dof / ((rs + 1.0) * (1.0 - rs))).clip(0)
              )
          finally:
              np.seterr(**olderr)
  
          prob = 2 * distributions.t.sf(np.abs(t), dof)
  
          # For backwards compatibility, return scalars when comparing 2 columns
          if rs.shape == (2, 2):
              return SpearmanrResult(rs[1, 0], prob[1, 0])
          else:
              return SpearmanrResult(rs, prob)
  
      # Need to do this per pair of variables, otherwise the dropped observations
      # in a third column mess up the result for a pair.
      n_vars = x.shape[1]
      if n_vars == 2:
          return _spearmanr_2cols(x)
      else:
          rs = np.ones((n_vars, n_vars), dtype=float)
          prob = np.zeros((n_vars, n_vars), dtype=float)
          for var1 in range(n_vars - 1):
              for var2 in range(var1 + 1, n_vars):
                  result = _spearmanr_2cols(x[:, [var1, var2]])
                  rs[var1, var2] = result.correlation
                  rs[var2, var1] = result.correlation
                  prob[var1, var2] = result.pvalue
                  prob[var2, var1] = result.pvalue
  
          return SpearmanrResult(rs, prob)
  
imports: from __future__ import division, print_function, absolute_import
  import numpy
  from numpy import ndarray
  import numpy.ma
  from numpy.ma import masked, nomask
  from scipy._lib.six import iteritems
  import itertools
  import warnings
  from collections import namedtuple
  from .None import distributions
  import scipy.special
  from ._stats_mstats_common import _find_repeats, linregress, theilslopes, siegelslopes
label_desc: Use image node_id 12 for calling a global function with example usage: spearmanr(x, y, use_ties, axis, nan_policy) and returns: _spearmanr_2cols, SpearmanrResult, SpearmanrResult, SpearmanrResult