I have updated my question with more details which hopefully will make it easier to work out what is happening.
I am using Pycharm debugging tools to get the information.
The exception message “Unable to get repr for <class ‘torch.Tensor’>” happens on this line

imgs = imgs.to(Constants.device)