What is txn doing and is the code working without using this library?
If so, try to use num_workers=0 in your DataLoader (if not already done) and rerun it.
If that’s working, the txn lib might run into some multiprocessing issues with the PyTorch DataLoader.
PS: You can add code snippets by wrapping them into three backticks ```, which makes debugging a bit easier.