Swarm optimisation

I would like to implement swarm optimisation using pytorch. How to do that in pytorch for a neural network?