dl_noob:

is dec recorded for automatic differentiation and does it affect the differentiation for decoder_output and rest of the graph?


The assignment should be recorded and the inplace operation could yield an error.
You could detach dec from decoder_output, if you don’t want to track this assignment.



 dl_noob:

Also, is accessing dec[i] inside a for loop possible if dec is a torch.cuda tensor?


Yes, that’s possible.