Best way to create std::vector from torch::Tensor

I need to create std::vector containers from the rows of a 2D tensor. I can slice the tensor to get the rows, and I need to convert those rows to std::vector. One option is, of course, to access all elements one by one, but there must be a better way to do it.

P.S. I don’t need to take ownership of the data, though I would appreciate it if there’s specific to be done when we want to do a deep copy.