Change `flatten` in the Tensor class to flatten the tensor in `self.matrix` from left to right, row by row.
