parameters: (a, offset=0)
return_statement: return _mx_nd_np.trace(a, offset=offset, axis1=0, axis2=1, out=None)
docstring: r"""
      Returns a tensor contraction of `a` and `b` over specific axes.
  
      Notes
      -----
      `trace` is an alias for `trace`. It is a standard API in
      https://data-apis.org/array-api/latest/extensions/linear_algebra_functions.html#linalg-trace-x-offset-0
      instead of an official NumPy operator.
  
      Parameters
      ----------
      a : ndarray
          Input array having shape (..., M, N) and whose innermost two dimensions form MxN matrices.
          Should have a numeric data type.
      offset : int
          Offset specifying the off-diagonal relative to the main diagonal.
  
          offset = 0 : the main diagonal.
          offset > 0 : off-diagonal above the main diagonal.
          offset < 0 : off-diagonal below the main diagonal.
  
          Default: 0.
  
      Returns
      ----------
      out : ndarray
          An array containing the traces and whose shape is determined by removing the last two dimensions and storing
          the traces in the last array dimension. For example, if `a` has rank `k` and shape `(I, J, K, ..., L, M, N)`,
          then an output array has rank `k-2` and shape `(I, J, K, ..., L)`
          where: `out[i, j, k, ..., l] = trace(a[i, j, k, ..., l, :, :])`
          The returned array must have the same data type as `a`.
  
      Examples
      --------
      >>> x = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
      >>> np.linalg.trace(x)
      array(3.)
      >>> x = np.arange(8).reshape((2, 2, 2))
      >>> np.linalg.trace(x)
      array([6., 8.])
      >>> x = np.arange(24).reshape((2, 2, 2, 3))
      >>> np.linalg.trace(x).shape
      (2, 3)
      >>> np.linalg.trace(x)
      array([[18., 20., 22.],
          [24., 26., 28.]])
docstring_summary: r"""
      Returns a tensor contraction of `a` and `b` over specific axes.
docstring_tokens: r Returns a tensor contraction of a and b over specific axes .
function: def trace(a, offset=0):
      r"""
      Returns a tensor contraction of `a` and `b` over specific axes.
  
      Notes
      -----
      `trace` is an alias for `trace`. It is a standard API in
      https://data-apis.org/array-api/latest/extensions/linear_algebra_functions.html#linalg-trace-x-offset-0
      instead of an official NumPy operator.
  
      Parameters
      ----------
      a : ndarray
          Input array having shape (..., M, N) and whose innermost two dimensions form MxN matrices.
          Should have a numeric data type.
      offset : int
          Offset specifying the off-diagonal relative to the main diagonal.
  
          offset = 0 : the main diagonal.
          offset > 0 : off-diagonal above the main diagonal.
          offset < 0 : off-diagonal below the main diagonal.
  
          Default: 0.
  
      Returns
      ----------
      out : ndarray
          An array containing the traces and whose shape is determined by removing the last two dimensions and storing
          the traces in the last array dimension. For example, if `a` has rank `k` and shape `(I, J, K, ..., L, M, N)`,
          then an output array has rank `k-2` and shape `(I, J, K, ..., L)`
          where: `out[i, j, k, ..., l] = trace(a[i, j, k, ..., l, :, :])`
          The returned array must have the same data type as `a`.
  
      Examples
      --------
      >>> x = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
      >>> np.linalg.trace(x)
      array(3.)
      >>> x = np.arange(8).reshape((2, 2, 2))
      >>> np.linalg.trace(x)
      array([6., 8.])
      >>> x = np.arange(24).reshape((2, 2, 2, 3))
      >>> np.linalg.trace(x).shape
      (2, 3)
      >>> np.linalg.trace(x)
      array([[18., 20., 22.],
          [24., 26., 28.]])
      """
      # axis1, axis2: defaults are the first two axes of `a`.
      return _mx_nd_np.trace(a, offset=offset, axis1=0, axis2=1, out=None)
function_tokens: def trace ( a , offset = 0 ) : # axis1, axis2: defaults are the first two axes of `a`. return _mx_nd_np . trace ( a , offset = offset , axis1 = 0 , axis2 = 1 , out = None )