code: def grad_eig(ans, x):
      """Gradient of a general square (complex valued) matrix"""
      e, u = ans  # eigenvalues as 1d array, eigenvectors in columns
      n = e.shape[-1]
  
      def vjp(g):
          ge, gu = g
          ge = _matrix_diag(ge)
          f = 1 / (
              e[..., anp.newaxis, :] - e[..., :, anp.newaxis] + 1.0e-20
          )
          f -= _diag(f)
          ut = anp.swapaxes(u, -1, -2)
          r1 = f * _dot(ut, gu)
          r2 = -f * (
              _dot(
                  _dot(ut, anp.conj(u)),
                  anp.real(_dot(ut, gu)) * anp.eye(n),
              )
          )
          r = _dot(_dot(inv(ut), ge + r1 + r2), ut)
          if not anp.iscomplexobj(x):
              r = anp.real(r)
              # the derivative is still complex for real input (imaginary delta is allowed), real output
              # but the derivative should be real in real input case when imaginary delta is forbidden
          return r
  
      return vjp
  
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 10 for calling a global function with example usage: grad_eig(ans, x) and returns: vjp, r