code: def randomized_range_finder(A, n_dims, n_iter=2, random_state=None):
      """Computes an orthonormal matrix (Q) whose range approximates the range of A,  i.e., Q Q^H A ≈ A
  
      Parameters
      ----------
      A : 2D-array
      n_dims : int, dimension of the returned subspace
      n_iter : int, number of power iterations to conduct (default = 2)
      random_state: {None, int, np.random.RandomState}
  
      Returns
      -------
      Q : 2D-array
          of shape (A.shape[0], min(n_dims, A.shape[0], A.shape[1]))
  
      Notes
      -----
      This function is implemented based on Algorith 4.4 in `Finding structure with randomness:
      Probabilistic algorithms for constructing approximate matrix decompositions`
      - Halko et al (2009)
      """
      rng = tl.check_random_state(random_state)
      dim_1, dim_2 = tl.shape(A)
      Q = tl.tensor(rng.normal(size=(dim_2, n_dims)), **tl.context(A))
      Q, _ = tl.qr(tl.dot(A, Q))
  
      # Perform power iterations when spectrum decays slowly
      A_H = tl.conj(tl.transpose(A))
      for i in range(n_iter):
          Q, _ = tl.qr(tl.dot(A_H, Q))
          Q, _ = tl.qr(tl.dot(A, Q))
  
      return Q
  
file_path: tensorly/tensorly/tenalg/svd.py
imports: import warnings
  import tensorly
  from .proximal import soft_thresholding
label_desc: Use image node_id 3 for calling a global function with example usage: randomized_range_finder(A, n_dims, n_iter, random_state) and returns: Q