code: def test_pinv_solve():
      # Fully determined system (unique result, identical to other solvers).
      A = Matrix([[1, 5], [7, 9]])
      B = Matrix([12, 13])
      assert A.pinv_solve(B) == A.cholesky_solve(B)
      assert A.pinv_solve(B) == A.LDLsolve(B)
      assert A.pinv_solve(B) == Matrix(
          [sympify("-43/26"), sympify("71/26")]
      )
      assert A * A.pinv() * B == B
      # Fully determined, with two-dimensional B matrix.
      B = Matrix([[12, 13, 14], [15, 16, 17]])
      assert A.pinv_solve(B) == A.cholesky_solve(B)
      assert A.pinv_solve(B) == A.LDLsolve(B)
      assert (
          A.pinv_solve(B)
          == Matrix([[-33, -37, -41], [69, 75, 81]]) / 26
      )
      assert A * A.pinv() * B == B
      # Underdetermined system (infinite results).
      A = Matrix([[1, 0, 1], [0, 1, 1]])
      B = Matrix([5, 7])
      solution = A.pinv_solve(B)
      w = {}
      for s in solution.atoms(Symbol):
          # Extract dummy symbols used in the solution.
          w[s.name] = s
      assert solution == Matrix(
          [
              [w["w0_0"] / 3 + w["w1_0"] / 3 - w["w2_0"] / 3 + 1],
              [w["w0_0"] / 3 + w["w1_0"] / 3 - w["w2_0"] / 3 + 3],
              [-w["w0_0"] / 3 - w["w1_0"] / 3 + w["w2_0"] / 3 + 4],
          ]
      )
      assert A * A.pinv() * B == B
      # Overdetermined system (least squares results).
      A = Matrix([[1, 0], [0, 0], [0, 1]])
      B = Matrix([3, 2, 1])
      assert A.pinv_solve(B) == Matrix([3, 1])
      # Proof the solution is not exact.
      assert A * A.pinv() * B != B
  
imports: import pytest
  from sympy.core.function import expand_mul
  from sympy.core.numbers import I, Rational
  from sympy.core.singleton import S
  from sympy.core.symbol import Symbol, symbols
  from sympy.core.sympify import sympify
  from sympy.simplify.simplify import simplify
  from sympy.matrices.exceptions import ShapeError, NonSquareMatrixError
  from sympy.matrices import ImmutableMatrix, Matrix, eye, ones, ImmutableDenseMatrix, dotprodsimp
  from sympy.matrices.determinant import _det_laplace
  from sympy.testing.pytest import raises
  from sympy.matrices.exceptions import NonInvertibleMatrixError
  from sympy.polys.matrices.exceptions import DMShapeError
  from sympy.solvers.solveset import linsolve
  from sympy.abc import x, y
label_desc: Use image node_id 13 for calling a global function with example usage: test_pinv_solve() without return types