code: def grad_kron(argnum, ans, orig_A, orig_B):
      # kron has different promotion rules than dot. the reshapes are necessary if
      # and only if (1) orig_B is 1D or (2) orig_A and/or orig_B are 0D
      orig_A_shape = anp.shape(orig_A)
      orig_B_shape = anp.shape(orig_B)
  
      def vjp(G):
          A, B = anp.atleast_2d(orig_A), anp.atleast_2d(orig_B)
          shape = list(A.shape + B.shape)
          n = anp.ndim(A)
          shape[n - 1], shape[n] = shape[n], shape[n - 1]
          reshaped_G = anp.swapaxes(anp.reshape(G, shape), n - 1, n)
          if argnum == 0:
              return match_complex(
                  orig_A,
                  anp.reshape(
                      anp.tensordot(reshaped_G, B, axes=anp.ndim(B)),
                      orig_A_shape,
                  ),
              )
          else:
              return match_complex(
                  orig_B,
                  anp.reshape(
                      anp.tensordot(A, reshaped_G, axes=anp.ndim(A)),
                      orig_B_shape,
                  ),
              )
  
      return vjp
  
imports: from __future__ import absolute_import
  from six import string_types
  from functools import partial
  import numpy
  from ..util import func
  from .None import numpy_wrapper
  from .numpy_boxes import ArrayBox
  from autograd.extend import primitive, vspace, defvjp, defvjp_argnum, SparseObject, VJPNode, register_notrace
label_desc: Use image node_id 6 for calling a global function with example usage: grad_kron(argnum, ans, orig_A, orig_B) and returns: vjp, match_complex, match_complex