adv_ex is already a numpy array, so you can’t call .numpy() again on it (which is a tensor method).
Store adv_ex as a tensor or avoid calling numpy on it:
adv_ex = perturbed_data.squeeze().detach().cpu()
adv_examples.append( (init_pred.item(), final_pred.item(), adv_ex) )