code: def test_tsqr(m, n, chunks, error_type):
      mat = cupy.random.default_rng().random((m, n))
      data = da.from_array(mat, chunks=chunks, name="A", asarray=False)
  
      # qr
      m_q = m
      n_q = min(m, n)
      m_r = n_q
      n_r = n
  
      # svd
      m_u = m
      n_u = min(m, n)
      n_s = n_q
      m_vh = n_q
      n_vh = n
      d_vh = max(m_vh, n_vh)  # full matrix returned
  
      if error_type is None:
          # test QR
          q, r = da.linalg.tsqr(data)
          assert_eq((m_q, n_q), q.shape)  # shape check
          assert_eq((m_r, n_r), r.shape)  # shape check
          assert_eq(mat, da.dot(q, r))  # accuracy check
          assert_eq(
              cupy.eye(n_q, n_q), da.dot(q.T, q)
          )  # q must be orthonormal
          assert_eq(
              r, np.triu(r.rechunk(r.shape[0]))
          )  # r must be upper triangular
  
          # test SVD
          u, s, vh = da.linalg.tsqr(data, compute_svd=True)
          s_exact = np.linalg.svd(mat)[1]
          assert_eq(s, s_exact)  # s must contain the singular values
          assert_eq((m_u, n_u), u.shape)  # shape check
          assert_eq((n_s,), s.shape)  # shape check
          assert_eq((d_vh, d_vh), vh.shape)  # shape check
          assert_eq(
              np.eye(n_u, n_u), da.dot(u.T, u), check_type=False
          )  # u must be orthonormal
          assert_eq(
              np.eye(d_vh, d_vh), da.dot(vh, vh.T), check_type=False
          )  # vh must be orthonormal
          assert_eq(
              mat, da.dot(da.dot(u, da.diag(s)), vh[:n_q])
          )  # accuracy check
      else:
          with pytest.raises(error_type):
              q, r = da.linalg.tsqr(data)
          with pytest.raises(error_type):
              u, s, vh = da.linalg.tsqr(data, compute_svd=True)
  
file_path: dask/dask/array/tests/test_cupy_linalg.py
imports: from __future__ import annotations
  import numpy
  import pytest
  from packaging.version import parse
  import dask.array
  from dask.array.utils import assert_eq
label_desc: Use image node_id 1 for calling a global function with example usage: test_tsqr(m, n, chunks, error_type) without return types