code: def _estimate_rank_from_s(s, tol="auto", tol_kind="absolute"):
      """Estimate the rank of a matrix from its singular values.
  
      Parameters
      ----------
      s : ndarray, shape (..., ndim)
          The singular values of the matrix.
      tol : float | ``'auto'``
          Tolerance for singular values to consider non-zero in calculating the
          rank. Can be 'auto' to use the same thresholding as
          ``scipy.linalg.orth`` (assuming np.float64 datatype) adjusted
          by a factor of 2.
      tol_kind : str
          Can be ``"absolute"`` or ``"relative"``.
  
      Returns
      -------
      rank : ndarray, shape (...)
          The estimated rank.
      """
      s = np.array(s, float)
      max_s = np.amax(s, axis=-1)
      if isinstance(tol, str):
          if tol not in ("auto", "float32"):
              raise ValueError(
                  'tol must be "auto" or float, got %r' % (tol,)
              )
          # XXX this should be float32 probably due to how we save and
          # load data, but it breaks test_make_inverse_operator (!)
          # The factor of 2 gets test_compute_covariance_auto_reg[None]
          # to pass without breaking minimum norm tests. :(
          # Passing 'float32' is a hack workaround for test_maxfilter_get_rank :(
          if tol == "float32":
              eps = np.finfo(np.float32).eps
          else:
              eps = np.finfo(np.float64).eps
          tol = s.shape[-1] * max_s * eps
          if s.ndim == 1:  # typical
              logger.info(
                  "    Using tolerance %0.2g (%0.2g eps * %d dim * %0.2g"
                  "  max singular value)" % (tol, eps, len(s), max_s)
              )
      elif not (isinstance(tol, np.ndarray) and tol.dtype.kind == "f"):
          tol = float(tol)
          if tol_kind == "relative":
              tol = tol * max_s
  
      rank = np.sum(s > tol, axis=-1)
      return rank
  
file_path: mne-python/mne/rank.py
imports: import numpy
  from scipy import linalg
  from ._fiff.meas_info import Info, _simplify_info
  from ._fiff.pick import _picks_by_type, _picks_to_idx, pick_channels_cov, pick_info
  from ._fiff.proj import make_projector
  from .defaults import _handle_default
  from .utils import _apply_scaling_cov, _check_on_missing, _check_rank, _compute_row_norms, _on_missing, _pl, _scaled_array, _undo_scaling_cov, _validate_type, fill_doc, logger, verbose, warn
label_desc: Use image node_id 2 for calling a global function with example usage: _estimate_rank_from_s(s, tol, tol_kind) and returns: rank