code: def test_lstsq():
      m, n, k = 4, 3, 2
  
      # test dimensions
      a = T.randn((m, n))
      b = T.randn((m, k))
      x, res, *_ = T.lstsq(a, b)
      assert_equal(x.shape, (n, k))
  
      # test residuals
      assert_array_almost_equal(
          T.norm(T.dot(a, x) - b, axis=0) ** 2, res
      )
      rank = 2
      a = T.dot(T.randn((m, rank)), T.randn((rank, n)))
      _, res, *_ = T.lstsq(a, b)
      assert_array_almost_equal(tl.tensor([]), res)
  
      # test least squares solution
      a = T.randn((m, n))
      x = T.randn((n,))
      b = T.dot(a, x)
      x_lstsq, *_ = T.lstsq(a, b)
      assert_array_almost_equal(T.dot(a, x_lstsq), b, decimal=5)
  
imports: from concurrent.futures import ThreadPoolExecutor
  import pytest
  from time import time
  import numpy
  from scipy.linalg import svd
  from scipy import special
  import tensorly
  from ..None import backend
  from ..testing import assert_allclose, assert_array_equal, assert_equal, assert_, assert_array_almost_equal, assert_raises
  from tensorly.tenalg.svd import SVD_FUNS, svd_interface
label_desc: Use image node_id 15 for calling a global function with example usage: test_lstsq() without return types