I got it to work however v.unsqueeze(0).expand(-1, len(v)) seems to give an empty tensor - on which unsqueeze(2) obviously fails.
I got it to work passing the batch size instead of -1.
v.unsqueeze(0).expand(M_batch.size(0), len(v)).unsqueeze(2)