code: def randomized_svd(
      M,
      n_components,
      n_oversamples=10,
      n_iter="auto",
      power_iteration_normalizer="auto",
      transpose="auto",
      flip_sign=True,
      random_state=0,
  ):
      r"""
      Computes a truncated randomized SVD
  
      .. versionadded:: 0.1.4
  
      Parameters
      ----------
      M : Tensor
          tensor to decompose
      n_components : int
          Number of singular values and vectors to extract.
      n_oversamples : int (default is 10)
          Additional number of random vectors to sample the range of M so as
          to ensure proper conditioning. The total number of random vectors
          used to find the range of M is n_components + n_oversamples. Smaller
          number can improve speed but can negatively impact the quality of
          approximation of singular vectors and singular values.
      n_iter : int or 'auto' (default is 'auto')
          Number of power iterations. It can be used to deal with very noisy
          problems. When 'auto', it is set to 4, unless `n_components` is small
          (< .1 * min(X.shape)) `n_iter` in which case is set to 7.
          This improves precision with few components.
      power_iteration_normalizer : 'auto' (default), 'QR', 'LU', 'none'
          Whether the power iterations are normalized with step-by-step
          QR factorization (the slowest but most accurate), 'none'
          (the fastest but numerically unstable when `n_iter` is large, e.g.
          typically 5 or larger), or 'LU' factorization (numerically stable
          but can lose slightly in accuracy). The 'auto' mode applies no
          normalization if `n_iter` <= 2 and switches to LU otherwise.
      transpose : True, False or 'auto' (default)
          Whether the algorithm should be applied to M.T instead of M. The
          result should approximately be the same. The 'auto' mode will
          trigger the transposition if M.shape[1] > M.shape[0] since this
          implementation of randomized SVD tend to be a little faster in that
          case.
      flip_sign : boolean, (True by default)
          The output of a singular value decomposition is only unique up to a
          permutation of the signs of the singular vectors. If `flip_sign` is
          set to `True`, the sign ambiguity is resolved by making the largest
          loadings for each component in the left singular vectors positive.
      random_state : int, RandomState instance or None, optional (default=None)
          The seed of the pseudo random number generator to use when shuffling
          the data.  If int, random_state is the seed used by the random number
          generator; If RandomState instance, random_state is the random number
          generator; If None, the random number generator is the RandomState
          instance used by `np.random`.
      Notes
      -----
      This algorithm finds a (usually very good) approximate truncated
      singular value decomposition using randomization to speed up the
      computations. It is particularly fast on large matrices on which
      you wish to extract only a small number of components. In order to
      obtain further speed up, `n_iter` can be set <=2 (at the cost of
      loss of precision).
      References
      ----------
      * Finding structure with randomness: Stochastic algorithms for constructing
        approximate matrix decompositions
        Halko, et al., 2009 https://arxiv.org/abs/0909.4061
      * A randomized algorithm for the decomposition of matrices
        Per-Gunnar Martinsson, Vladimir Rokhlin and Mark Tygert
      * An implementation of a randomized algorithm for principal component
        analysis
        A. Szlam et al. 2014
      """
      M = astensor(M)
      random_state = check_random_state(random_state)
      n_random = n_components + n_oversamples
      n_samples, n_features = M.shape
  
      if n_iter == "auto":
          # Check if the number of iterations is explicitly specified
          # Adjust n_iter. 7 was found a good compromise for PCA.
          # https://github.com/scikit-learn/scikit-learn/pull/5299
          n_iter = 7 if n_components < 0.1 * min(M.shape) else 4
  
      if transpose == "auto":
          transpose = n_samples < n_features
      if transpose:
          # this implementation is a bit faster with smaller shape[1]
          M = M.T
  
      Q = randomized_range_finder(
          M, n_random, n_iter, power_iteration_normalizer, random_state
      )
      # project M to the (k + p) dimensional space using the basis vectors
      B = Q.T.dot(M)
  
      # compute the SVD on the thin matrix: (k + p) wide
      Uhat, s, V = svd(B)
  
      U = Q.dot(Uhat)
  
      if flip_sign:
          if not transpose:
              U, V = svd_flip(U, V)
          else:
              # In case of transpose u_based_decision=false
              # to actually flip based on u and not v.
              U, V = svd_flip(U, V, u_based_decision=False)
  
      if transpose:
          # transpose back the results according to the input convention
          return (
              V[:n_components, :].T,
              s[:n_components],
              U[:, :n_components].T,
          )
      else:
          return (
              U[:, :n_components],
              s[:n_components],
              V[:n_components, :],
          )
  
file_path: mars/mars/tensor/linalg/randomized_svd.py
imports: from ..utils import check_random_state
  from ..datasource import tensor
  from .lu import lu
  from .qr import qr
  from .svd import svd
  from .utils import svd_flip
label_desc: Use image node_id 2 for calling a global function with example usage: randomized_svd(M, n_components, n_oversamples, n_iter, power_iteration_normalizer, transpose, flip_sign, random_state) and returns: V,  s,  U, U,  s,  V