code: def trace(expr):
      """Trace of a Matrix.  Sum of the diagonal elements.
  
      Examples
      ========
  
      >>> from sympy import trace, Symbol, MatrixSymbol, eye
      >>> n = Symbol('n')
      >>> X = MatrixSymbol('X', n, n)  # A square matrix
      >>> trace(2*X)
      2*Trace(X)
      >>> trace(eye(3))
      3
      """
      return Trace(expr).doit()
  
imports: from sympy.core.basic import Basic
  from sympy.core.expr import Expr, ExprBuilder
  from sympy.core.singleton import S
  from sympy.core.sorting import default_sort_key
  from sympy.core.symbol import uniquely_named_symbol
  from sympy.core.sympify import sympify
  from sympy.matrices.matrixbase import MatrixBase
  from sympy.matrices.exceptions import NonSquareMatrixError
label_desc: Use image node_id 1 for calling a global function with example usage: trace(expr) and returns: Trace