The problem were the imports. The correct imports are
#include <ATen/core/ATen_fwd.h>
#include <torch/csrc/autograd/generated/variable_factories.h>
It seems like the Libtorch headers are very well hidden. To find any import search the function (in C/C++ code aka with :: instead of .) on https://pytorch.org/, then click on “defined in [file_name].h” and look under “Definition”. There is the full import path.