Yes, in PyTorch, because of autograd, a for-loop is completely compatible with backpropagation. Autograd builds the computational graph dynamically, recording operations and their predecessors as they occur, so backpropagation will just work. I included a link to an autograd tutorial in my previous response.