Replace TensorContract to mark contracted pairs. This is cleaner than
map functions onto TensorContract.