code: def test_pinv():
      def fun(x):
          return np.linalg.pinv(x)
  
      N = 5
      D = 2
      ## Non-square matrices:
      for M in range(N // 2, N + N // 2 + 1):
          mat = npr.randn(N, M)
          check_grads(fun)(mat)
          # Stacked
          mat = npr.randn(D, N, M)
          check_grads(fun)(mat)
  
      ## Square, low (fixed) rank matrices
      def fun_low_rank(x):
          return np.linalg.pinv(np.linalg._dot(np.linalg.T(x), x))
  
      for M in range(N // 2, N + N // 2 + 1):
          mat = npr.randn(N, M)
          check_grads(fun_low_rank)(mat)
          # Stacked
          mat = npr.randn(D, N, M)
          check_grads(fun_low_rank)(mat)
  
imports: from __future__ import absolute_import
  from builtins import range
  import itertools
  import autograd.numpy
  import autograd.numpy.random
  from autograd.test_util import check_grads
  from autograd import tuple
  from autograd import grad
  from functools import partial
  import pytest
label_desc: Use image node_id 4 for calling a global function with example usage: test_pinv() and returns: np, np