Added a trace function to Tensor.