code: def diagonal(x: Array, /, *, offset: int = 0) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.diagonal <numpy.diagonal>`.
  
      See its docstring for more information.
      """
      # Note: diagonal always operates on the last two axes, whereas np.diagonal
      # operates on the first two axes by default
      return Array._new(
          np.diagonal(x._array, offset=offset, axis1=-2, axis2=-1)
      )
  
imports: from __future__ import annotations
  from ._dtypes import _floating_dtypes, _numeric_dtypes, float32, float64, complex64, complex128
  from ._manipulation_functions import reshape
  from ._array_object import Array
  from ..core.numeric import normalize_axis_tuple
  from typing import TYPE_CHECKING
  from typing import NamedTuple
  import numpy.linalg
  import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: diagonal() and returns: Array