Are these shapes returned for all batches?
The error suggests that the batch size was larger than 1:

RuntimeError: stack expects each tensor to be equal size, but got [0] at entry 0 and [1] at entry 1