First, please read API document carefully:

torch.multiprocessing.spawn(fn, args=(), nprocs=1, join=True, daemon=False, start_method=‘spawn’)


Parameters

fn (function) – …The function is called as fn(i, *args), where i is the process index and args is the passed through tuple of arguments.
args (tuple) – Arguments passed to fn.
nprocs (int) – Number of processes to spawn.



Returns
None if join is True, ProcessContext if join is False

First, you should call your function as:
if __name__ == '__main__':
    # start with 4 processes
    # your original method will invoke your function as X_power_func(0, 0, 1, 2, 3)
    spawn(X_power_func, nprocs=4)

Secondly, do not put result at:
if __name__ == '__main__':
    results = spawn(X_power_func, range(4), nprocs=1)

results

Because in your subprocesses, they will try to access “results”, but since they are not “main”, “results” is not defined,
Thirdly, spawn will not return results.

Returns
None if join is True, ProcessContext if join is False

In summary, please re-read documents, they take a lot of time to write.