I don’t know any super optimized way of doing this. But this could be useful:
#include <torch/torch.h>
#include <iostream>

int main(){
	std::vector<std::vector<int>> x = {{1, 2}, {3, 4}};
	torch::Tensor tensor = torch::zeros({2, 2}).to(torch::kInt);
	int n = x.size();
	for(int i = 0; i < n; i++){
		std::memcpy(tensor.data<int>() + i * n, &x[i][0], 2 * sizeof(int));
	}
	std::cout<< tensor << std::endl;
	return 0;
}

There, you can kind of save a nested for loop, since std::memcpy is very fast.