Thank you for your reply. The code works properly in some versions, and in some others the error changes to:
  File "main.py", line 140, in <module>
    main(config)
  File "main.py", line 80, in main
    solver.train()
  File "/project/6027897/meyta/Joint/4-11/Compile_nets.py", line 344, in train
    loss.backward()
  File "/home/meyta/ENV/lib/python3.6/site-packages/torch/tensor.py", line 221, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph)
  File "/home/meyta/ENV/lib/python3.6/site-packages/torch/autograd/__init__.py", line 132, in backward
    allow_unreachable=True)  # allow_unreachable flag
RuntimeError: label is too far

I tried with a few systems and versions, but I couldn’t find out what was the exact source of the error. So, reproducing errors is not straightforward for me. Now, the code is working on my system but I still face the error on the server (computecanada).