I haven’t used the C++ dataparallel API yet, but you might want to take a look at this test 12.
I’m unsure about the status of DDP in libtorch, which is the recommended approach for performance reasons.