code: def diagonal(
      x: np.ndarray,
      /,
      *,
      offset: int = 0,
      axis1: int = -2,
      axis2: int = -1,
      out: Optional[np.ndarray] = None,
  ) -> np.ndarray:
      return np.diagonal(x, offset=offset, axis1=axis1, axis2=axis2)
  
imports: from collections import namedtuple
  from typing import Union, Optional, Tuple, Literal, List, NamedTuple, Sequence
  import numpy
  import ivy
  from ivy import inf
  from ivy.func_wrapper import with_unsupported_dtypes
  from ivy.functional.backends.numpy.helpers import _scalar_output_to_0d_array
  from .None import backend_version
label_desc: Use image node_id 4 for calling a global function with example usage: diagonal() and returns: np