Shisho_Sama:

imgs.grad.requires_grad = True


imgs is a tensor right? so I think it should be
imgs.requires_grad = True

Maybe this FSGM Tutorial 98 is helpful since it also relies on getting the gradient with respect to the input.