Inconsistent Tensor Sizes

I am implementing VQA in pytorch and I am getting this error when I train the model.

RuntimeError: inconsistent tensor sizes at /pytorch/torch/lib/TH/generic/THTensorMath.c:2864

The loss decreases for certain batches, but then I get this error. Can anyone tell me what the problem is?

I am attaching my code below.
https://drive.google.com/file/d/13jRiTiP7zPU8DmyZx34L3YZZKnm8J9Yr/view?usp=sharing

I solved it. The image dimensions were not consistent. Just converted them to an RGB format.