Reduce memory usage in grid_of_tensors_3D_to_2D when contracting vertically. Also fix a bug with the base case.
Reduce memory usage in grid_of_tensors_3D_to_2D when contracting vertically. Also fix a bug with the base case.

ngnrsaa/qflex,ngnrsaa/qflex,ngnrsaa/qflex,ngnrsaa/qflex