I’m not sure, why this indexing is needed here:
output = model(b_x)[0]    

as it would only use the first sample in the batch and will raise the error, since the batch dimension is missing.
Removing it should solve the issue, but you should check, why it was used in the first place.