code: def trace(
      x: paddle.Tensor,
      /,
      *,
      offset: int = 0,
      axis1: int = 0,
      axis2: int = 1,
      out: Optional[paddle.Tensor] = None,
  ) -> paddle.Tensor:
      ret = paddle.trace(x, offset=offset, axis1=axis1, axis2=axis2)
      return ret.squeeze() if x.ndim <= 2 else ret
  
imports: import paddle
  from typing import Union, Optional, Tuple, Literal, List, NamedTuple, Sequence
  from collections import namedtuple
  import ivy
  from ivy import inf
  from ivy.utils.exceptions import IvyNotImplementedException
  import ivy.functional.backends.paddle
  from .None import backend_version
  from ivy.func_wrapper import with_unsupported_device_and_dtypes, with_unsupported_dtypes, with_supported_dtypes
  from .elementwise import _elementwise_helper
label_desc: Use image node_id 24 for calling a global function with example usage: trace() and returns: unknown