class_docstr: Matrix Trace
  
  Represents the trace of a matrix expression.
  
  Examples
  ========
  
  >>> from sympy import MatrixSymbol, Trace, eye
  >>> A = MatrixSymbol('A', 3, 3)
  >>> Trace(A)
  Trace(A)
  >>> Trace(eye(3))
  Trace(Matrix([
  [1, 0, 0],
  [0, 1, 0],
  [0, 0, 1]]))
  >>> Trace(eye(3)).simplify()
  3
class_docstr_tok: ["Matrix","Trace","Represents","the","trace","of","a","matrix","expression",".","Examples","========",">",">",">","from","sympy","import","MatrixSymbol",",","Trace",",","eye",">",">",">","A","=","MatrixSymbol","(","'","A","'",",","3",",","3",")",">",">",">","Trace","(","A",")","Trace","(","A",")",">",">",">","Trace","(","eye","(","3",")",")","Trace","(","Matrix","(","[","[","1",",","0",",","0","]",",","[","0",",","1",",","0","]",",","[","0",",","0",",","1","]","]",")",")",">",">",">","Trace","(","eye","(","3",")",")",".simplify","(",")","3"]
code: def _normalize(self):
      # Normalization of trace of matrix products. Use transposition and
      # cyclic properties of traces to make sure the arguments of the matrix
      # product are sorted and the first argument is not a transposition.
      from sympy.matrices.expressions.matmul import MatMul
      from sympy.matrices.expressions.transpose import Transpose
  
      trace_arg = self.arg
      if isinstance(trace_arg, MatMul):
  
          def get_arg_key(x):
              a = trace_arg.args[x]
              if isinstance(a, Transpose):
                  a = a.arg
              return default_sort_key(a)
  
          indmin = min(range(len(trace_arg.args)), key=get_arg_key)
          if isinstance(trace_arg.args[indmin], Transpose):
              trace_arg = Transpose(trace_arg).doit()
              indmin = min(
                  range(len(trace_arg.args)),
                  key=lambda x: default_sort_key(trace_arg.args[x]),
              )
          trace_arg = MatMul.fromiter(
              trace_arg.args[indmin:] + trace_arg.args[:indmin]
          )
          return Trace(trace_arg)
      return self
  
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 8 for calling the Trace obj's underlying member method code with example usage: obj._normalize() and returns: self, Trace, default_sort_key