Thanks, Is it possible to do the following:
                model.module.layer2.requires_grad_(False)
                model.module.layer1.requires_grad_(False)
                out = model(input_var,first=1)
                loss_1 = criterion(out, t)
                optimizer.zero_grad()
                loss_1.backward(retain_graph=True)

And then:
                model.module.layer2.requires_grad_(True)
                model.module.layer1.requires_grad_(True)
                loss_2 = criterion(out, t)
                optimizer.zero_grad()
                loss_2.backward()

Means, does the .requires_grad_(True) option need to be submitted in the forward pass of the network, or it can be also before the forward pass