NLLLoss from docs: The target that this loss expects should be a class index in the range [0,C−1] where C = number of classes (instead of one hot vectors). You can use argmax on the stacked tensor (preferably just change the way you load the targets).
Example:
std::vector<double> data1(112);
std::vector<double> data2(112);
std::vector<double> label1 = { 0, 1 };
std::vector<double> label2 = { 1, 0 };

auto inputs = torch::stack({ torch::tensor(data1), torch::tensor(data2) });
auto labels = torch::stack({ torch::tensor(label1), torch::tensor(label2) });

auto model = std::make_unique<TorchNet>(112);

auto output = model->forward(inputs);

labels = torch::argmax(labels, 1);
		
auto loss = torch::nll_loss(output, labels);