Turning an existing optimization package to a PyTorch Optimizer

Hello, I wanted to convert torchswarm- an existing PSO library- for use in training a PyTorch neural network.

The PSO optimizer of torchswarm takes in inputs: objective function, dimensions, swarm size and maximum iterations.

I have made progress in creating a class that uses torch.optim.optimizer and transfer the neural net dimensions to the PSO optimizer of torch swarm.

However, I am stuck in creating the step function inside the optimizer class. Specifically, how do I code for updating the weights of the neural net using the output of the PSO optimizer.

Please help.