that is because in most tutorials there is the torch::data::transforms::Stack<>() transform applied to the dataset. It converts your std::vector<torch::data::Example> into one Tensor. Check out the MNIST example, there you will find this line
auto test_dataset = torch::data::datasets::MNIST(
kDataRoot, torch::data::datasets::MNIST::Mode::kTest)
.map(torch::data::transforms::Normalize<>(0.1307, 0.3081))
.map(torch::data::transforms::Stack<>()); // this is where the magic happens. It internally
// calls torch::stack on a
// std::vector<torch::Tensor>
You could also loop over your std::vector<torch::data::Example> and access your data of every torch::data::Example as you mentioned. Does this solve your problem?