Like python, torch::Tensor has the view method to
You could do the following -
#include<torch/torch.h>

auto tensor = torch::rand({1, 2, 3 ,5});
tensor = tensor.view(tensor.size(0), -1); //Here the shape of the data is batch, num_tensors
tensor = tensor.contiguous();
std::vector<float> vector(tensor.data_ptr<float>(), tensor.data_ptr<float>()+tensor.numel());