code: def diagonal(a, offset=0, axis1=0, axis2=1):
      """Returns specified diagonals.
  
      This function extracts the diagonals along two specified axes. The other
      axes are not changed. This function returns a writable view of this array
      as NumPy 1.10 will do.
  
      Args:
          a (cupy.ndarray): Array from which the diagonals are taken.
          offset (int): Index of the diagonals. Zero indicates the main
              diagonals, a positive value upper diagonals, and a negative value
              lower diagonals.
          axis1 (int): The first axis to take diagonals from.
          axis2 (int): The second axis to take diagonals from.
  
      Returns:
          cupy.ndarray: A view of the diagonals of ``a``.
  
      .. seealso:: :func:`numpy.diagonal`
  
      """
      # TODO(okuta): check type
      return a.diagonal(offset, axis1, axis2)
  
file_path: cupy/cupy/_indexing/indexing.py
imports: import cupy
  from cupy._core import internal
label_desc: Use image node_id 5 for calling a global function with example usage: diagonal(a, offset, axis1, axis2) and returns: a