Ninja: build stopped: subcommand failed. note: see declaration of 'PyDict_GetItem'

BAG-OF-CHIPS-XX: <p>Hello community! This is my first post so I apologize if I am doing something wrong. I am running into an issue when trying to build pytorch-1.12.1 from source. I have search the web for a solution but cannot find one. I am not familiar with C++ so this stuff can become quite confusing to me.<br>
Here are some specs of my system:<br>
(CUDNN 8.9.4,CUDA 11.4,GPU Arch 86, Visual Studio 16 2019, cmake 3.27.1, Windows 10, 3080 GPU)<br>
and these are the commands I run where I run into an error:<br>
git clone --branch v1.12.1 <a href="https://github.com/pytorch/pytorch.git" class="inline-onebox" rel="noopener nofollow ugc">GitHub - pytorch/pytorch: Tensors and Dynamic neural networks in Python with strong GPU acceleration</a> pytorch-1.12.1<br>
cd pytorch-1.12.1<br>
git submodule sync<br>
git submodule deinit -f .<br>
git submodule update --init --recursive<br>
pip install -r requirements.txt<br>
python setup.py build</p>
<p>after building for some time I start to get errors and end up with this in my terminal:</p>
<pre><code class="lang-auto">(haloapi) C:\pytorch-1.12.1&gt;python setup.py build
Building wheel torch-1.12.0a0+git664058f
-- Building version 1.12.0a0+git664058f
cmake --build . --target install --config Release
[2/153] Building CXX object caffe2\torch\CMakeFile...src\autograd\generated\python_return_types.cpp.obj
FAILED: caffe2/torch/CMakeFiles/torch_python.dir/csrc/autograd/generated/python_return_types.cpp.obj
C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\cl.exe  /nologo /TP -DAT_PER_OPERATOR_HEADERS -DBUILDING_TESTS -DFMT_HEADER_ONLY=1 -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DONNXIFI_ENABLE_EXT=1 -DONNX_ML=1 -DONNX_NAMESPACE=onnx_torch -DTHP_BUILD_MAIN_LIB -DUSE_CUDA -DUSE_CUDNN -DUSE_EXTERNAL_MZCRC -DUSE_NUMPY -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE=1 -Dtorch_python_EXPORTS -IC:\pytorch-1.12.1\build\aten\src -IC:\pytorch-1.12.1\aten\src -IC:\pytorch-1.12.1\build -IC:\pytorch-1.12.1 -IC:\pytorch-1.12.1\cmake\..\third_party\benchmark\include -IC:\pytorch-1.12.1\cmake\..\third_party\cudnn_frontend\include -IC:\pytorch-1.12.1\third_party\onnx -IC:\pytorch-1.12.1\build\third_party\onnx -IC:\pytorch-1.12.1\third_party\foxi -IC:\pytorch-1.12.1\build\third_party\foxi -IC:\pytorch-1.12.1\torch\.. -IC:\pytorch-1.12.1\torch\..\aten\src -IC:\pytorch-1.12.1\torch\..\aten\src\TH -IC:\pytorch-1.12.1\build\caffe2\aten\src -IC:\pytorch-1.12.1\build\third_party -IC:\pytorch-1.12.1\torch\..\third_party\valgrind-headers -IC:\pytorch-1.12.1\torch\..\third_party\gloo -IC:\pytorch-1.12.1\torch\..\third_party\onnx -IC:\pytorch-1.12.1\torch\..\third_party\flatbuffers\include -IC:\pytorch-1.12.1\torch\csrc -IC:\pytorch-1.12.1\torch\csrc\api\include -IC:\pytorch-1.12.1\torch\lib -IC:\pytorch-1.12.1\torch\lib\libshm_windows -IC:\pytorch-1.12.1\torch\csrc\distributed -IC:\pytorch-1.12.1\torch\csrc\api -IC:\pytorch-1.12.1\c10\.. -IC:\pytorch-1.12.1\c10\cuda\..\.. -IC:\pytorch-1.12.1\third_party\fmt\include -external:IC:\pytorch-1.12.1\cmake\..\third_party\googletest\googlemock\include -external:IC:\pytorch-1.12.1\cmake\..\third_party\googletest\googletest\include -external:IC:\pytorch-1.12.1\third_party\protobuf\src -external:IC:\pytorch-1.12.1\third_party\XNNPACK\include -external:IC:\pytorch-1.12.1\cmake\..\third_party\eigen -external:I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\include" -external:IC:\pytorch-1.12.1\third_party\ideep\mkl-dnn\third_party\oneDNN\include -external:IC:\pytorch-1.12.1\third_party\ideep\include -external:IC:\Anaconda3\envs\haloapi\include -external:IC:\Anaconda3\envs\haloapi\Lib\site-packages\numpy\core\include -external:I"C:\Program Files\NVIDIA Corporation\NvToolsExt\include" -external:IC:\pytorch-1.12.1\cmake\..\third_party\pybind11\include -external:W0 /DWIN32 /D_WINDOWS /GR /EHsc /w /bigobj -DUSE_PTHREADPOOL -openmp:experimental -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DUSE_FBGEMM -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -DHAVE_AVX512_CPU_DEFINITION -DHAVE_AVX2_CPU_DEFINITION /MD /O2 /Ob2 /DNDEBUG /w /bigobj -DNDEBUG -std:c++14 -DTH_HAVE_THREAD /EHsc /DNOMINMAX /wd4267 /wd4251 /wd4522 /wd4838 /wd4305 /wd4244 /wd4190 /wd4101 /wd4996 /wd4275 /bigobj /showIncludes /Focaffe2\torch\CMakeFiles\torch_python.dir\csrc\autograd\generated\python_return_types.cpp.obj /Fdcaffe2\torch\CMakeFiles\torch_python.dir\ /FS -c C:\pytorch-1.12.1\torch\csrc\autograd\generated\python_return_types.cpp
C:\pytorch-1.12.1\third_party\pybind11\include\pybind11\cast.h(446): error C2027: use of undefined type '_frame'
C:\Anaconda3\envs\haloapi\include\pytypedefs.h(22): note: see declaration of '_frame'
C:\pytorch-1.12.1\third_party\pybind11\include\pybind11\cast.h(448): error C2027: use of undefined type '_frame'
C:\Anaconda3\envs\haloapi\include\pytypedefs.h(22): note: see declaration of '_frame'
C:\pytorch-1.12.1\third_party\pybind11\include\pybind11\cast.h(449): error C2027: use of undefined type '_frame'
C:\Anaconda3\envs\haloapi\include\pytypedefs.h(22): note: see declaration of '_frame'
C:\pytorch-1.12.1\cmake\..\third_party\pybind11\include\pybind11/pybind11.h(2291): error C2039: 'frame': is not a member of '_ts'
C:\Anaconda3\envs\haloapi\include\cpython/pystate.h(82): note: see declaration of '_ts'
C:\pytorch-1.12.1\cmake\..\third_party\pybind11\include\pybind11/pybind11.h(2292): error C2027: use of undefined type '_frame'
C:\Anaconda3\envs\haloapi\include\pytypedefs.h(22): note: see declaration of '_frame'
C:\pytorch-1.12.1\cmake\..\third_party\pybind11\include\pybind11/pybind11.h(2293): error C2027: use of undefined type '_frame'
C:\Anaconda3\envs\haloapi\include\pytypedefs.h(22): note: see declaration of '_frame'
C:\pytorch-1.12.1\cmake\..\third_party\pybind11\include\pybind11/pybind11.h(2296): error C2027: use of undefined type '_frame'
C:\Anaconda3\envs\haloapi\include\pytypedefs.h(22): note: see declaration of '_frame'
C:\pytorch-1.12.1\cmake\..\third_party\pybind11\include\pybind11/pybind11.h(2295): error C2660: 'PyDict_GetItem': function does not take 1 arguments
C:\Anaconda3\envs\haloapi\include\dictobject.h(22): note: see declaration of 'PyDict_GetItem'
</code></pre>
<p>Any help or recommendations on what I should try or due to fix this issue is appreciated as I am totally stuck now.</p>