Problem in Implementing a PGM

I am sorry that I am asking way too many questions @fehiepsi !

I changed the dimensions as you mentioned. It works fine when I sample from my model. But I encounter this error when I run MCMC on it: RuntimeError: The size of tensor a (2) must match the size of tensor b (2115) at non-singleton dimension 0

I also print the shape of ‘l’ and ‘e’ during the inference and I saw something that I don’t understand:
l : (2115, 1)
e: (10)
l: (2, 1, 1)
e: (10)

Why does the shape of ‘e’ changes to (2, 1, 1) in the second iteration?

I really appreciate your help!