code: def trace(a, offset=0, axis1=0, axis2=1, dtype=None, out=None):
      """Returns the sum along the diagonals of an array.
  
      It computes the sum along the diagonals at ``axis1`` and ``axis2``.
  
      Args:
          a (cupy.ndarray): Array to take trace.
          offset (int): Index of diagonals. Zero indicates the main diagonal, a
              positive value an upper diagonal, and a negative value a lower
              diagonal.
          axis1 (int): The first axis along which the trace is taken.
          axis2 (int): The second axis along which the trace is taken.
          dtype: Data type specifier of the output.
          out (cupy.ndarray): Output array.
  
      Returns:
          cupy.ndarray: The trace of ``a`` along axes ``(axis1, axis2)``.
  
      .. seealso:: :func:`numpy.trace`
  
      """
      # TODO(okuta): check type
      return a.trace(offset, axis1, axis2, dtype, out)
  
file_path: cupy/cupy/linalg/_norms.py
imports: import numpy
  import cupy
  from cupy import _core
  from cupy.linalg import _decomposition
  from cupy.linalg import _util
  import functools
label_desc: Use image node_id 6 for calling a global function with example usage: trace(a, offset, axis1, axis2, dtype, out) and returns: a