code: def eye(N, dtype=np.float32):
      """
      Construct a 2D matrix with ones on the diagonal and zeros elsewhere.
  
      Constructs a matrix in device memory whose diagonal elements
      are set to 1 and non-diagonal elements are set to 0.
  
      Parameters
      ----------
      N : int
          Number of rows or columns in the output matrix.
      dtype : type
          Matrix data type.
  
      Returns
      -------
      e_gpu : pycuda.gpuarray.GPUArray
          Diagonal matrix of dimensions `[N, N]` with diagonal values
          set to 1.
  
      Examples
      --------
      >>> import pycuda.driver as drv
      >>> import pycuda.gpuarray as gpuarray
      >>> import pycuda.autoinit
      >>> import numpy as np
      >>> import skcuda.linalg as linalg
      >>> linalg.init()
      >>> N = 5
      >>> e_gpu = linalg.eye(N)
      >>> np.all(e_gpu.get() == np.eye(N))
      True
      >>> e_gpu = linalg.eye(N, np.complex64)
      >>> np.all(e_gpu.get() == np.eye(N, dtype=np.complex64))
      True
  
      """
  
      if dtype not in [
          np.float32,
          np.float64,
          np.complex64,
          np.complex128,
      ]:
          raise ValueError("unrecognized type")
      if N <= 0:
          raise ValueError("N must be greater than 0")
      alloc = misc._global_cublas_allocator
  
      e_gpu = misc.zeros((N, N), dtype, allocator=alloc)
      func = _get_eye_kernel(dtype)
      func(e_gpu, slice=slice(0, N * N, N + 1))
      return e_gpu
  
imports: from __future__ import absolute_import, division
  from pprint import pprint
  from string import Template
  from pycuda.tools import context_dependent_memoize
  from pycuda.compiler import SourceModule
  from pycuda.reduction import ReductionKernel
  from pycuda import cumath
  import pycuda.gpuarray
  import pycuda.driver
  import pycuda.elementwise
  import pycuda.tools
  import numpy
  from .None import cublas
  from .None import cudart
  from .None import misc
  from .None import cusolver
  import sys
  from .misc import init, shutdown, add_matvec, div_matvec, mult_matvec
  from .None import install_headers
label_desc: Use image node_id 18 for calling a global function with example usage: eye(N, dtype) and returns: e_gpu