transfer_matrix works but tensor stack hogs memory