code: def vec_to_diag(vec):
      """Convert vector to diagonal matrix."""
      d = vec.shape[-1]
      return _np.squeeze(
          vec[..., None, :] * eye(d, dtype=vec.dtype)[None, :, :]
      )
  
imports: from ._dispatch import BACKEND_NAME, _common
  from ._dispatch import numpy
label_desc: Use image node_id 18 for calling a global function with example usage: vec_to_diag(vec) and returns: _np