code: def grad_solve_banded(argnum, ans, l_and_u, a, b):
      updim = lambda x: x if x.ndim == a.ndim else x[..., None]
  
      def transpose_banded(l_and_u, a):
          # Compute the transpose of a banded matrix.
          # The transpose is itself a banded matrix.
  
          num_rows = a.shape[0]
  
          shifts = anp.arange(-l_and_u[1], l_and_u[0] + 1)
  
          T_a = anp.roll(a[:1, :], shifts[0])
          for rr in range(1, num_rows):
              T_a = anp.vstack(
                  [
                      T_a,
                      anp.flipud(
                          anp.roll(a[rr : rr + 1, :], shifts[rr])
                      ),
                  ]
              )
          T_a = anp.flipud(T_a)
  
          T_l_and_u = anp.flip(l_and_u)
  
          return T_l_and_u, T_a
  
      def banded_dot(l_and_u, uu, vv):
          # Compute tensor product of vectors uu and vv.
          # Tensor product elements are resticted to the bands specified by l_and_u.
  
          # TODO: replace the brute-force ravel() by smarter dimension handeling of uu and vv
  
          # main diagonal
          banded_uv = anp.ravel(uu) * anp.ravel(vv)
  
          # stack below the sub-diagonals
          for rr in range(1, l_and_u[0] + 1):
              banded_uv_rr = anp.hstack(
                  [
                      anp.ravel(uu)[rr:] * anp.ravel(vv)[:-rr],
                      anp.zeros(rr),
                  ]
              )
              banded_uv = anp.vstack([banded_uv, banded_uv_rr])
  
          # stack above the sup-diagonals
          for rr in range(1, l_and_u[1] + 1):
              banded_uv_rr = anp.hstack(
                  [
                      anp.zeros(rr),
                      anp.ravel(uu)[:-rr] * anp.ravel(vv)[rr:],
                  ]
              )
              banded_uv = anp.vstack([banded_uv_rr, banded_uv])
  
          return banded_uv
  
      T_l_and_u, T_a = transpose_banded(l_and_u, a)
  
      if argnum == 1:
          return lambda g: -banded_dot(
              l_and_u,
              updim(solve_banded(T_l_and_u, T_a, g)),
              anp.transpose(updim(ans)),
          )
      elif argnum == 2:
          return lambda g: solve_banded(T_l_and_u, T_a, g)
  
file_path: autograd/autograd/scipy/linalg.py
imports: from __future__ import division
  from functools import partial
  import scipy.linalg
  import autograd.numpy
  from autograd.numpy.numpy_wrapper import wrap_namespace
  from autograd.extend import defvjp, defvjp_argnums, defjvp, defjvp_argnums
label_desc: Use image node_id 4 for calling a global function with example usage: grad_solve_banded(argnum, ans, l_and_u, a, b) and returns: T_l_and_u,  T_a, banded_uv, function, function