aclifton314:

Also, how would I go about assigning the gathered tensor to a variable for further processing inside the main() function?


You can create a pipe in the main process and pass it to the child processes. Then the child processes can write the cosine_tensor to the pipe which the main process can read and process. You can read these docs to better understand how to use a pipe for communication: multiprocessing — Process-based parallelism — Python 3.10.0 documentation 1