code: def test_inv():
      a = mt.random.randint(1, 10, (20, 20), chunk_size=8)
      a_inv = tile(mt.linalg.inv(a))
  
      assert a_inv.shape == (20, 20)
  
      # test 1 chunk
      a = mt.random.randint(1, 10, (20, 20), chunk_size=20)
      a_inv = tile(mt.linalg.inv(a))
  
      assert a_inv.shape == (20, 20)
      assert len(a_inv.chunks) == 1
      assert isinstance(a_inv.chunks[0].op, TensorInv)
  
      a = mt.random.randint(1, 10, (20, 20), chunk_size=11)
      a_inv = tile(mt.linalg.inv(a))
  
      assert a_inv.shape == (20, 20)
      assert a_inv.nsplits == ((11, 9), (11, 9))
  
      b = a.T.dot(a)
      b_inv = tile(mt.linalg.inv(b))
      assert b_inv.shape == (20, 20)
  
      # test sparse
      data = sps.csr_matrix(np.random.randint(1, 10, (20, 20)))
      a = mt.tensor(data, chunk_size=10)
      a_inv = tile(mt.linalg.inv(a))
  
      assert a_inv.shape == (20, 20)
  
      assert a_inv.op.sparse is True
      assert isinstance(a_inv, SparseTensor)
      assert all(c.is_sparse() for c in a_inv.chunks) is True
  
      b = a.T.dot(a)
      b_inv = tile(mt.linalg.inv(b))
      assert b_inv.shape == (20, 20)
  
      assert b_inv.op.sparse is True
      assert isinstance(b_inv, SparseTensor)
      assert all(c.is_sparse() for c in b_inv.chunks) is True
  
      b_inv = tile(mt.linalg.inv(b, sparse=False))
      assert b_inv.op.sparse is False
      assert not all(c.is_sparse() for c in b_inv.chunks) is True
  
file_path: mars/mars/tensor/linalg/tests/test_linalg.py
imports: import numpy
  import scipy.sparse
  import pytest
  from ....None import tensor
  from ....core import tile
  from ...None import ones, tensor, dot, empty
  from ...core import SparseTensor, Tensor
  from ..None import matmul
  from ..inv import TensorInv
label_desc: Use image node_id 6 for calling a global function with example usage: test_inv() without return types