C++ implementation of generic DNN trainer using Torch C++ API