Thank you for your response. I get the following error when executing that code:
mask = mask.unsqueeze(1) # should have shape 1, 1, 100, 100
AttributeError: 'bool' object has no attribute 'unsqueeze'

since mask is a bool from mask = out[:,class_idx,:,:] == torch.max(out, dim=1).
What are we trying to accomplish from this line? How should we rewrite it to make mask a tensor and not a bool? Thank you!