Firstly, you should use boxes.size(). Secondly, https://pytorch.org/docs/stable/jit.html#disable-jit-for-debugging 22 will give you some help and my tip is using @torch.jit.ignore to check the functionality.