class_docstr: Sparse matrix with DIAgonal storage.
  
  Now it has only one initializer format below:
  
  ``dia_matrix((data, offsets))``
  
  Args:
      arg1: Arguments for the initializer.
      shape (tuple): Shape of a matrix. Its length must be two.
      dtype: Data type. It must be an argument of :class:`numpy.dtype`.
      copy (bool): If ``True``, copies of given arrays are always used.
  
  .. seealso::
     :class:`scipy.sparse.dia_matrix`
class_docstr_tok: ["Sparse","matrix","with","DIAgonal","storage",".","Now","it","has","only","one","initializer","format","below",":","``","dia_matrix","(","(","data",",","offsets",")",")","``","Args",":","arg1",":","Arguments","for","the","initializer",".","shape","(","tuple",")",":","Shape","of","a","matrix",".","Its","length","must","be","two",".","dtype",":","Data","type",".","It","must","be","an","argument","of",":","class",":","`","numpy.dtype","`",".","copy","(","bool",")",":","If","``","True","``",",","copies","of","given","arrays","are","always","used",".","..","seealso",":",":",":","class",":","`","scipy.sparse.dia_matrix","`"]
docstr: Returns the k-th diagonal of the matrix.
  
  Args:
      k (int, optional): Which diagonal to get, corresponding to elements
      a[i, i+k]. Default: 0 (the main diagonal).
  
  Returns:
      cupy.ndarray : The k-th diagonal.
docstr_tok: ["Returns","the","k-th","diagonal","of","the","matrix",".","Args",":","k","(","int",",","optional",")",":","Which","diagonal","to","get",",","corresponding","to","elements","a","[","i",",","i+k","]",".","Default",":","0","(","the","main","diagonal",")",".","Returns",":","cupy.ndarray",":","The","k-th","diagonal","."]
code: def diagonal(self, k=0):
      """Returns the k-th diagonal of the matrix.
  
      Args:
          k (int, optional): Which diagonal to get, corresponding to elements
          a[i, i+k]. Default: 0 (the main diagonal).
  
      Returns:
          cupy.ndarray : The k-th diagonal.
      """
      rows, cols = self.shape
      if k <= -rows or k >= cols:
          return cupy.empty(0, dtype=self.data.dtype)
      (idx,) = cupy.nonzero(self.offsets == k)
      first_col, last_col = max(0, k), min(rows + k, cols)
      if idx.size == 0:
          return cupy.zeros(last_col - first_col, dtype=self.data.dtype)
      return self.data[idx[0], first_col:last_col]
  
file_path: cupy/cupyx/scipy/sparse/_dia.py
imports: import cupy
  from cupy import _core
  from cupyx.scipy.sparse import _csc
  from cupyx.scipy.sparse import _data
  from cupyx.scipy.sparse import _util
label_desc: Use image node_id 9 for calling the dia_matrix obj's underlying member method code with example usage: obj.diagonal(k) and returns: self, cupy, cupy