You can just give the parameters of N2 to the optimizer that you choose.
The code can look like
optimizer = torch.optim.Adam(N2.parameters(), blah blah)
input = Variable(sth)
N1_out = N1(input)
N2_out = N2(N1_out)
loss = compute_loss(N2_out)
...