parameters: (x, name=None)
docstring: Compute the trace of a tensor `x`.
  
    `trace(x)` returns the sum of along the diagonal.
  
    For example:
  
    ```python
    # 'x' is [[1, 1],
    #         [1, 1]]
    tf.trace(x) ==> 2
  
    # 'x' is [[1,2,3],
    #         [4,5,6],
    #         [7,8,9]]
    tf.trace(x) ==> 15
    ```
  
    Args:
      x: 2-D tensor.
      name: A name for the operation (optional).
  
    Returns:
      The trace of input tensor.
docstring_summary: Compute the trace of a tensor `x`.
docstring_tokens: Compute the trace of a tensor x .
function: def trace(x, name=None):
    """ Compute the trace of a tensor `x`.
  
    `trace(x)` returns the sum of along the diagonal.
  
    For example:
  
    ```python
    # 'x' is [[1, 1],
    #         [1, 1]]
    tf.trace(x) ==> 2
  
    # 'x' is [[1,2,3],
    #         [4,5,6],
    #         [7,8,9]]
    tf.trace(x) ==> 15
    ```
  
    Args:
      x: 2-D tensor.
      name: A name for the operation (optional).
  
    Returns:
      The trace of input tensor.
    """
    with ops.op_scope([x], name, "Trace") as name:
      x = ops.convert_to_tensor(x, name="x")
      if len(x.get_shape()) != 2:
        raise ValueError("Expected a tensor with rank 2, rank %d tensor received"
                         % len(x.get_shape()))
      return reduce_sum(array_ops.diag_part(x), name=name)
function_tokens: def trace ( x , name = None ) : with ops . op_scope ( [ x ] , name , "Trace" ) as name : x = ops . convert_to_tensor ( x , name = "x" ) if len ( x . get_shape ( ) ) != 2 : raise ValueError ( "Expected a tensor with rank 2, rank %d tensor received" % len ( x . get_shape ( ) ) ) return reduce_sum ( array_ops . diag_part ( x ) , name = name )