@pytorchnewbie I think the point was about using if epoch %20 ==0 inside foo which is one of possible implementations.
If you would like to setup customized event filtering other than every, please see the usage of event_filter  argument : https://pytorch.org/ignite/engine.html#ignite.engine.events.Events 1