code: def eye(m, n=None, k=0, dtype="d", format=None):
      """Creates a sparse matrix with ones on diagonal.
  
      Args:
          m (int): Number of rows.
          n (int or None): Number of columns. If it is ``None``,
              it makes a square matrix.
          k (int): Diagonal to place ones on.
          dtype: Type of a matrix to create.
          format (str or None): Format of the result, e.g. ``format="csr"``.
  
      Returns:
          cupyx.scipy.sparse.spmatrix: Created sparse matrix.
  
      .. seealso:: :func:`scipy.sparse.eye`
  
      """
      if n is None:
          n = m
      m, n = int(m), int(n)
  
      if m == n and k == 0:
          if format in ["csr", "csc"]:
              indptr = cupy.arange(n + 1, dtype="i")
              indices = cupy.arange(n, dtype="i")
              data = cupy.ones(n, dtype=dtype)
              if format == "csr":
                  cls = _csr.csr_matrix
              else:
                  cls = _csc.csc_matrix
              return cls((data, indices, indptr), (n, n))
  
          elif format == "coo":
              row = cupy.arange(n, dtype="i")
              col = cupy.arange(n, dtype="i")
              data = cupy.ones(n, dtype=dtype)
              return _coo.coo_matrix((data, (row, col)), (n, n))
  
      diags = cupy.ones((1, max(0, min(m + k, n))), dtype=dtype)
      return spdiags(diags, k, m, n).asformat(format)
  
file_path: cupy/cupyx/scipy/sparse/_construct.py
imports: import numpy
  import cupy
  from cupyx.scipy.sparse import _coo
  from cupyx.scipy.sparse import _csc
  from cupyx.scipy.sparse import _csr
  from cupyx.scipy.sparse import _dia
  from cupyx.scipy.sparse import _sputils
label_desc: Use image node_id 1 for calling a global function with example usage: eye(m, n, k, dtype, format) and returns: spdiags, cls, _coo