LIBTORCH/C++ and Unreal Engine 4 Runtime error: Variable is optimized away and not avaible

Solved my issue. Check the build configuration, if you use torchlib in release, build the project also in release.