code: def test_qr():
      a = mt.random.rand(9, 6, chunk_size=(3, 6))
      q, r = mt.linalg.qr(a)
  
      assert q.shape == (9, 6)
      assert r.shape == (6, 6)
  
      q, r = tile(q, r)
  
      assert len(q.chunks) == 3
      assert len(r.chunks) == 1
      assert q.nsplits == ((3, 3, 3), (6,))
      assert r.nsplits == ((6,), (6,))
  
      assert q.chunks[0].shape == (3, 6)
      assert q.chunks[0].inputs[0].shape == (3, 3)
      assert q.chunks[0].inputs[1].shape == (3, 6)
  
      a = mt.random.rand(18, 6, chunk_size=(9, 6))
      q, r = mt.linalg.qr(a)
  
      assert q.shape == (18, 6)
      assert r.shape == (6, 6)
  
      q, r = tile(q, r)
  
      assert len(q.chunks) == 2
      assert len(r.chunks) == 1
      assert q.nsplits == ((9, 9), (6,))
      assert r.nsplits == ((6,), (6,))
  
      assert q.chunks[0].shape == (9, 6)
      assert q.chunks[0].inputs[0].shape == (9, 6)
      assert q.chunks[0].inputs[1].shape == (6, 6)
  
      # for Short-and-Fat QR
      a = mt.random.rand(6, 18, chunk_size=(6, 6))
      q, r = mt.linalg.qr(a, method="sfqr")
  
      assert q.shape == (6, 6)
      assert r.shape == (6, 18)
  
      q, r = tile(q, r)
  
      assert len(q.chunks) == 1
      assert len(r.chunks) == 3
      assert q.nsplits == ((6,), (6,))
      assert r.nsplits == ((6,), (6, 6, 6))
  
      # chunk width less than height
      a = mt.random.rand(6, 9, chunk_size=(6, 3))
      q, r = mt.linalg.qr(a, method="sfqr")
  
      assert q.shape == (6, 6)
      assert r.shape == (6, 9)
  
      q, r = tile(q, r)
  
      assert len(q.chunks) == 1
      assert len(r.chunks) == 2
      assert q.nsplits == ((6,), (6,))
      assert r.nsplits == ((6,), (6, 3))
  
      a = mt.random.rand(9, 6, chunk_size=(9, 3))
      q, r = mt.linalg.qr(a, method="sfqr")
  
      assert q.shape == (9, 6)
      assert r.shape == (6, 6)
  
      q, r = tile(q, r)
  
      assert len(q.chunks) == 1
      assert len(r.chunks) == 1
      assert q.nsplits == ((9,), (6,))
      assert r.nsplits == ((6,), (6,))
  
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 1 for calling a global function with example usage: test_qr() without return types