It should be like that
def print_epoch(engine):
    print("The training epoch is: " + str(engine.state.epoch))

trainer.add_event_handler(
    Events.EPOCH_COMPLETED(every=1), print_epoch
)

print_epoch shouldn’t be called on the same line as trainer.add_event_handler.