code: def _matrix_diag(a):
      reps = anp.array(a.shape)
      reps[:-1] = 1
      reps[-1] = a.shape[-1]
      newshape = list(a.shape) + [a.shape[-1]]
      return _diag(anp.tile(a, reps).reshape(newshape))
  
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 2 for calling a global function with example usage: _matrix_diag(a) and returns: _diag