Add trace operation for tensors
Summary
This MR allows to compute the trace as the sum of the last two indices of a tensor. It is implemented in terms of the tensordot operation between the tensor and the identity-matrix. Not, the tensordot needs to be further improved to make this operation fast.