code: def spd_inv_sqrt(W, epsilon=1e-10, method='QR', return_rank=False):
      
      if _np.shape(W)[0] == 1:
          if W[0,0] < epsilon:
              raise _ZeroRankError(
                  'All eigenvalues are smaller than %g, rank reduction would discard all dimensions.' % epsilon)
          Winv = 1./_np.sqrt(W[0, 0])
          sm = _np.ones(1)
      else:
          sm, Vm = spd_eig(W, epsilon=epsilon, method=method)
          Winv = _np.dot(Vm, _np.diag(1.0 / _np.sqrt(sm))).dot(Vm.T)
  
      # return split
      if return_rank:
          return Winv, sm.shape[0]
      else:
          return Winv
docs: Computes :math:`W^{-1/2}` of symmetric positive-definite matrix :math:`W`.
  
      by first reducing W to a low-rank approximation that is truly spd.
  
      Parameters
      ----------
      W : ndarray((m,m), dtype=float)
          Symmetric positive-definite (spd) matrix.
      epsilon : float
          Truncation parameter. Eigenvalues with norms smaller than this cutoff will
          be removed.
      method : str
          Method to perform the decomposition of :math:`W` before inverting. Options are:
  
          * 'QR': QR-based robust eigenvalue decomposition of W
          * 'schur': Schur decomposition of W
  
      Returns
      -------
      L : ndarray((n, r))
          :math:`W^{-1/2}` after reduction of W to a low-rank spd matrix