this code demonstrates how spred can be implemented with pytorch simply.