


torch.allclose(A @ x, b)
      True
      >>> A = torch.randn(2, 3, 3)
      >>> B = torch.randn(2, 3, 4)
      >>> X = torch.linalg.solve(A, B)
      >>> X.shape
      torch.Size([2, 3, 4])
      >>> torch.allclose(A @ X, B)
      True



  >>> A = torch.randn(2, 3, 3)
  >>> b = torch.randn(3, 1)
  >>> x = torch.linalg.solve(A, b) # b is broadcasted to size (2, 3, 1)
  >>> x.shape
  torch.Size([2, 3, 1])
  >>> torch.allclose(A @ x, b)
  True
  >>> b = torch.randn(3)
  >>> x = torch.linalg.solve(A, b) # b is broadcasted to size (2, 3)
  >>> x.shape
  torch.Size([2, 3])
  >>> Ax = A @ x.unsqueeze(-1)
  >>> torch.allclose(Ax, b.unsqueeze(-1).expand_as(Ax))
  True
