Thank you for your example how to use libtorch to create own datasets- loaders. Ive followed your example and created a read_data() function that returns a tensor from a csv file by first creating a vector then flatten the vector and then creating tensors in the right shape by using from_blob.
Here is the output of my input and output vectors and tensors (each row is an observation):
Data Vector: 
9 1 4 2 6 
2 7 5 2 3 
4 3 7 8 5 
5 2 4 7 9 
Flat Vector: 
9 1 4 2 6 2 7 5 2 3 4 3 7 8 5 5 2 4 7 9 
Input Tensor: 
 9  1  4  2  6
 2  7  5  2  3
 4  3  7  8  5
 5  2  4  7  9
[ CPUDoubleType{4,5} ]
Data Vector: 
22 
19 
27 
27 
Flat Vector: 
22 19 27 27 
Output Tensor (target): 
 22
 19
 27
 27
[ CPUDoubleType{4,1} ]

Unfortunately if I use the class MyDataset in the main function I get the error:

a cast to abstract class “MyDataset” is not allowed: – pure virtual function “torch::data::datasets::BatchDataset<Self, Batch, BatchRequest>::size [with Self=MyDataset, Batch=std::vector<torch::data::Example<at::Tensor, at::Tensor>, std::allocator<torch::data::Example<at::Tensor, at::Tensor>>>, BatchRequest=c10::ArrayRef<size_t>]” has no overriderC/C++(389)

Im using the class like this:
auto data_set = MyDataset(input_loc, output_loc);
Can please someone help me out.
EDIT / SOLUTION:
Ok I solved it by also overriding the size() method like this:
torch::optional<size_t> size() const override {
      return labels_.size(0);
    };

Something that I also had to do to resolve all compilation errors was to pass the data_loader inside the for range loop by pointer like this:
for (auto& batch: *data_loader) { ... };

Otherwise it would not compile.
I really miss more Tutorials for the C++ API in the Documentation area. How Can I contribute to add more tutorials for the C++ API so that beginners like me dont have this issues?