code: def test_svd_linop():
      nmks = [(6, 7, 3), (9, 5, 4), (10, 8, 5)]
  
      def reorder(args):
          U, s, VH = args
          j = np.argsort(s)
          return U[:, j], s[j], VH[j, :]
  
      for n, m, k in nmks:
          # Test svds on a LinearOperator.
          A = np.random.RandomState(52).randn(n, m)
          L = CheckingLinearOperator(A)
  
          v0 = np.ones(min(A.shape))
  
          U1, s1, VH1 = reorder(svds(A, k, v0=v0))
          U2, s2, VH2 = reorder(svds(L, k, v0=v0))
  
          assert_allclose(np.abs(U1), np.abs(U2))
          assert_allclose(s1, s2)
          assert_allclose(np.abs(VH1), np.abs(VH2))
          assert_allclose(
              np.dot(U1, np.dot(np.diag(s1), VH1)),
              np.dot(U2, np.dot(np.diag(s2), VH2)),
          )
  
          # Try again with which="SM".
          A = np.random.RandomState(1909).randn(n, m)
          L = CheckingLinearOperator(A)
  
          U1, s1, VH1 = reorder(svds(A, k, which="SM"))
          U2, s2, VH2 = reorder(svds(L, k, which="SM"))
  
          assert_allclose(np.abs(U1), np.abs(U2))
          assert_allclose(s1, s2)
          assert_allclose(np.abs(VH1), np.abs(VH2))
          assert_allclose(
              np.dot(U1, np.dot(np.diag(s1), VH1)),
              np.dot(U2, np.dot(np.diag(s2), VH2)),
          )
  
          if k < min(n, m) - 1:
              # Complex input and explicit which="LM".
              for dt, eps in [(complex, 1e-7), (np.complex64, 1e-3)]:
                  rng = np.random.RandomState(1648)
                  A = (rng.randn(n, m) + 1j * rng.randn(n, m)).astype(
                      dt
                  )
                  L = CheckingLinearOperator(A)
  
                  U1, s1, VH1 = reorder(svds(A, k, which="LM"))
                  U2, s2, VH2 = reorder(svds(L, k, which="LM"))
  
                  assert_allclose(np.abs(U1), np.abs(U2), rtol=eps)
                  assert_allclose(s1, s2, rtol=eps)
                  assert_allclose(np.abs(VH1), np.abs(VH2), rtol=eps)
                  assert_allclose(
                      np.dot(U1, np.dot(np.diag(s1), VH1)),
                      np.dot(U2, np.dot(np.diag(s2), VH2)),
                      rtol=eps,
                  )
  
imports: from __future__ import division, print_function, absolute_import
  import threading
  import itertools
  import numpy
  from numpy.testing import assert_allclose, assert_array_almost_equal_nulp, assert_equal, assert_array_equal
  from pytest import raises
  import pytest
  from numpy import dot, conj, random
  from scipy.linalg import eig, eigh, hilbert, svd
  from scipy.sparse import csc_matrix, csr_matrix, isspmatrix, diags, rand
  from scipy.sparse.linalg import LinearOperator, aslinearoperator
  from scipy.sparse.linalg.eigen.arpack import eigs, eigsh, svds, ArpackNoConvergence, arpack
  from scipy._lib._gcutils import assert_deallocated, IS_PYPY
  from scipy._lib._numpy_compat import suppress_warnings
label_desc: Use image node_id 33 for calling a global function with example usage: test_svd_linop() and returns: U,  s,  VH