Hi,
Thank you so much for the quick reply! I am not sure if “multiprocessing” is the thing I need. The actual scenario is, I have a batch input with size “BxNxC”, and want to feed it into a layer named L (L consists of some differentiable operations without trainable parameters). However, L can only accept input with size “NxC”, so that I need to write a for loop to feed the whole batch.
I find that even if I manually replicate L with B times, it still go through sequentially. Then I turn to parallel computation topics  I am not sure if there is any method to speed up the “for loop” without touching the “L” function/layer?
I will take a look at the link you share, thanks!