code: def test_inv(setup):
      import scipy.linalg
  
      rs = np.random.RandomState(0)
  
      data = rs.randint(1, 10, (20, 20))
  
      A = tensor(data)
      inv_A = inv(A)
  
      res = inv_A.execute().fetch()
      np.testing.assert_allclose(res, scipy.linalg.inv(data))
      res = A.dot(inv_A).execute().fetch()
      np.testing.assert_array_almost_equal(
          res, np.eye(data.shape[0], dtype=float)
      )
  
      A = tensor(data, chunk_size=10)
      inv_A = inv(A)
  
      res = inv_A.execute().fetch()
      np.testing.assert_allclose(res, scipy.linalg.inv(data))
      res = A.dot(inv_A).execute().fetch()
      np.testing.assert_array_almost_equal(
          res, np.eye(data.shape[0], dtype=float)
      )
  
      # test 1 chunk
      A = tensor(data, chunk_size=20)
      inv_A = inv(A)
  
      res = inv_A.execute().fetch()
      np.testing.assert_allclose(res, scipy.linalg.inv(data))
      res = A.dot(inv_A).execute().fetch()
      np.testing.assert_array_almost_equal(
          res, np.eye(data.shape[0], dtype=float)
      )
  
      B = A.T.dot(A)
      inv_B = inv(B)
      res = inv_B.execute().fetch()
      np.testing.assert_array_almost_equal(
          res, scipy.linalg.inv(data.T.dot(data))
      )
      res = B.dot(inv_B).execute().fetch()
      np.testing.assert_array_almost_equal(
          res, np.eye(data.shape[0], dtype=float)
      )
  
      # test for not all chunks are square in matrix A
      A = tensor(data, chunk_size=8)
      inv_A = inv(A)
  
      res = inv_A.execute().fetch()
      np.testing.assert_array_almost_equal(res, scipy.linalg.inv(data))
      res = A.dot(inv_A).execute().fetch()
      np.testing.assert_array_almost_equal(
          res, np.eye(data.shape[0], dtype=float)
      )
  
      # test sparse
      data = rs.randint(1, 10, (20, 20))
      sp_data = sps.csr_matrix(data)
  
      A = tensor(sp_data, chunk_size=10)
      inv_A = inv(A)
  
      res = inv_A.execute().fetch()
      assert isinstance(res, SparseNDArray)
      np.testing.assert_array_almost_equal(res, scipy.linalg.inv(data))
      res = A.dot(inv_A).execute().fetch()
      np.testing.assert_array_almost_equal(
          res, np.eye(data.shape[0], dtype=float)
      )
  
      # test for not all chunks are square in matrix A
      A = tensor(sp_data, chunk_size=12)
      inv_A = inv(A)
  
      res = inv_A.execute().fetch()
      assert isinstance(res, SparseNDArray)
      np.testing.assert_array_almost_equal(res, scipy.linalg.inv(data))
      res = A.dot(inv_A).execute().fetch()
      np.testing.assert_array_almost_equal(
          res, np.eye(data.shape[0], dtype=float)
      )
  
imports: import numpy
  import scipy.sparse
  from ....learn.datasets.samples_generator import make_low_rank_matrix
  from ....lib.sparse import issparse, SparseNDArray
  from ....utils import ignore_warning
  from ...datasource import tensor, diag, ones, arange
  from ...random import uniform
  from ..None import qr, svd, cholesky, norm, lu, solve_triangular, solve, inv, tensordot, dot, inner, vdot, matmul, randomized_svd
label_desc: Use image node_id 9 for calling a global function with example usage: test_inv(setup) without return types