code: def randomized_range_finder(
      A,
      size,
      n_iter,
      power_iteration_normalizer="auto",
      random_state=None,
  ):
      r"""Computes an orthonormal matrix whose range approximates the range of A.
  
      .. versionadded:: 0.1.3
  
      Parameters
      ----------
      A : 2D tensor
          The input data tensor
  
      size : integer
          Size of the return tensor
  
      n_iter : integer
          Number of power iterations used to stabilize the result
  
      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.
  
      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`.
  
      Returns
      -------
      Q : 2D array
          A (size x size) projection matrix, the range of which
          approximates well the range of the input matrix A.
  
      Notes
      -----
  
      Follows Algorithm 4.3 of
      Finding structure with randomness: Stochastic algorithms for constructing
      approximate matrix decompositions
      Halko, et al., 2009 (arXiv:909) https://arxiv.org/pdf/0909.4061.pdf
  
      An implementation of a randomized algorithm for principal component
      analysis
      A. Szlam et al. 2014
      """
      random_state = check_random_state(random_state)
  
      # Generating normal random vectors with shape: (A.shape[1], size)
      Q = random_state.normal(size=(A.shape[1], size))
      if A.dtype.kind == "f":
          # Ensure f32 is preserved as f32
          Q = Q.astype(A.dtype, copy=False)
  
      # Deal with "auto" mode
      if power_iteration_normalizer == "auto":
          if n_iter <= 2:
              power_iteration_normalizer = "none"
          else:
              power_iteration_normalizer = "LU"
  
      # Perform power iterations with Q to further 'imprint' the top
      # singular vectors of A in Q
      for _ in range(n_iter):
          if power_iteration_normalizer == "none":
              Q = A.dot(Q)
              Q = A.T.dot(Q)
          elif power_iteration_normalizer == "LU":
              # TODO: directly get Q when lu supports `permute_l`
              p, l, _ = lu(A.dot(Q))
              Q = p.dot(l)
              p, l, _ = lu(A.T.dot(Q))
              Q = p.dot(l)
          elif power_iteration_normalizer == "QR":
              Q, _ = qr(A.dot(Q))
              Q, _ = qr(A.T.dot(Q))
  
      # Sample the range of A using by linear projection of Q
      # Extract an orthonormal basis
      Q, _ = qr(A.dot(Q))
      return Q
  
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 1 for calling a global function with example usage: randomized_range_finder(A, size, n_iter, power_iteration_normalizer, random_state) and returns: Q