code: def grad_pinv(ans, x):
      # https://mathoverflow.net/questions/25778/analytical-formula-for-numerical-derivative-of-the-matrix-pseudo-inverse
      return lambda g: T(
          -_dot(_dot(ans, T(g)), ans)
          + _dot(
              _dot(_dot(ans, T(ans)), g),
              anp.eye(x.shape[-2]) - _dot(x, ans),
          )
          + _dot(
              _dot(
                  _dot(anp.eye(ans.shape[-2]) - _dot(ans, x), g), T(ans)
              ),
              ans,
          )
      )
  
file_path: autograd/autograd/numpy/linalg.py
imports: from __future__ import absolute_import
  from functools import partial
  import numpy.linalg
  from .numpy_wrapper import wrap_namespace
  from .None import numpy_wrapper
  from autograd.extend import defvjp, defjvp
label_desc: Use image node_id 5 for calling a global function with example usage: grad_pinv(ans, x) and returns: function