Does backward propagate only with forward passed layer?

I am wondering that backward propagate only affect with the module that passed during forward.

for example I define generator as following and has condition term during forward pass.

class generator(nn.Module):                                                                                                                                                                
        def forward(self, input, noise, label):                                                                              
             x = encoder(input)          
             if idx == 0:                                                                                                     
              x = self.fc_style0(x)                                                                                          
            elif idx == 1:                                                                                                   
              x = self.fc_style1(x)                                                                                          
            elif idx == 2:                                           
              x = self.encoder(x)                                                                                                                                                                                 
             x = self.decoder(x, label)                                                                                       
             return x            

end

Then does parameter only update respect to fowardpass definition?
To be more specific if the idx was 0 then self.fc_style0 was used for forward. In backpropagation stage. self.fc_style1, and self.fc_style2 's params are not updated?

Only the modules that are used during the forward pass will be updated.