Hi!
Using @Michael_Petrochuk solution is enough:
import torch.multiprocessing
...
def test_worker_in_mpi():
    mp = torch.multiprocessing.get_context('forkserver')
    pool = mp.Pool(processes=1) # ,maxtasksperchild=1
    rez = pool.map(worker, params_iterator) 

And this was a pytest. At least for my toy example (inside the worker I create a 2 layer net and pass a tensor through it) it works without any main guard, maxtasksperchild=1 or
set_start_method
Thanks!