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 _eval_derivative_matrix_lines(self, x):
      from sympy.tensor.array.expressions.array_expressions import (
          ArrayTensorProduct,
          ArrayContraction,
      )
  
      r = self.args[0]._eval_derivative_matrix_lines(x)
      for lr in r:
          if lr.higher == 1:
              lr.higher = ExprBuilder(
                  ArrayContraction,
                  [
                      ExprBuilder(
                          ArrayTensorProduct,
                          [
                              lr._lines[0],
                              lr._lines[1],
                          ],
                      ),
                      (1, 3),
                  ],
                  validator=ArrayContraction._validate,
              )
          else:
              # This is not a matrix line:
              lr.higher = ExprBuilder(
                  ArrayContraction,
                  [
                      ExprBuilder(
                          ArrayTensorProduct,
                          [
                              lr._lines[0],
                              lr._lines[1],
                              lr.higher,
                          ],
                      ),
                      (1, 3),
                      (0, 2),
                  ],
              )
          lr._lines = [S.One, S.One]
          lr._first_pointer_parent = lr._lines
          lr._second_pointer_parent = lr._lines
          lr._first_pointer_index = 0
          lr._second_pointer_index = 1
      return r
  
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 4 for calling the Trace obj's underlying member method code with example usage: obj._eval_derivative_matrix_lines(x) and returns: r