code: def randomized_svd(
      matrix,
      n_eigenvecs=None,
      n_oversamples=5,
      n_iter=2,
      random_state=None,
      **kwargs,
  ):
      """Computes a truncated randomized SVD.
  
      If `n_eigenvecs` is specified, sparse eigendecomposition is used on
      either matrix.dot(matrix.T) or matrix.T.dot(matrix).
  
      Parameters
      ----------
      matrix : tensor
          A 2D tensor.
      n_eigenvecs : int, optional, default is None
          If specified, number of eigen[vectors-values] to return.
      n_oversamples: int, optional, default = 5
          rank overestimation value for finiding subspace with better allignment
      n_iter: int, optional, default = 2
          number of power iterations for the `randomized_range_finder` subroutine
      random_state: {None, int, np.random.RandomState}
      **kwargs : optional
          kwargs are used to absorb the difference of parameters among the other SVD functions
  
      Returns
      -------
      U : 2-D tensor, shape (matrix.shape[0], n_eigenvecs)
          Contains the right singular vectors
      S : 1-D tensor, shape (n_eigenvecs, )
          Contains the singular values of `matrix`
      V : 2-D tensor, shape (n_eigenvecs, matrix.shape[1])
          Contains the left singular vectors
  
      Notes
      -----
      This function is implemented based on Algorith 5.1 in `Finding structure with randomness:
      Probabilistic algorithms for constructing approximate matrix decompositions`
      - Halko et al (2009)
      """
      n_eigenvecs, min_dim, max_dim = svd_checks(
          matrix, n_eigenvecs=n_eigenvecs
      )
  
      dim_1, dim_2 = tl.shape(matrix)
      n_dims = min(n_eigenvecs + n_oversamples, max_dim)
  
      if (
          dim_1 > dim_2
          and n_eigenvecs > min(min_dim, n_dims)
          or dim_1 < dim_2
          and n_eigenvecs < min(min_dim, n_dims)
      ):
          # transpose matrix to keep the reduced matrix shape minimal
          matrix_T = tl.transpose(matrix)
          Q = randomized_range_finder(
              matrix_T,
              n_dims=n_dims,
              n_iter=n_iter,
              random_state=random_state,
          )
          Q_H = tl.conj(tl.transpose(Q))
          matrix_reduced = tl.transpose(tl.dot(Q_H, matrix_T))
          U, S, V = truncated_svd(
              matrix_reduced, n_eigenvecs=n_eigenvecs
          )
          V = tl.dot(V, tl.transpose(Q))
      else:
          Q = randomized_range_finder(
              matrix,
              n_dims=n_dims,
              n_iter=n_iter,
              random_state=random_state,
          )
          Q_H = tl.conj(tl.transpose(Q))
          matrix_reduced = tl.dot(Q_H, matrix)
          U, S, V = truncated_svd(
              matrix_reduced, n_eigenvecs=n_eigenvecs
          )
          U = tl.dot(Q, U)
  
      return U, S, V
  
file_path: tensorly/tensorly/tenalg/svd.py
imports: import warnings
  import tensorly
  from .proximal import soft_thresholding
label_desc: Use image node_id 7 for calling a global function with example usage: randomized_svd(matrix, n_eigenvecs, n_oversamples, n_iter, random_state) and returns: U,  S,  V