There might be some syntax issue since you are applying it directly in the for loop. Try this and see if it works:
---> 18 for idx, (img, label_attr, label_idx) in enumerate(final_train_generator):
19 l = train_agent.fit_final_classifier(img.cuda(), label_attr.cuda(), label_idx.cuda())
20 syn_loss += l