I am sending an abstract of my code. I am sending data and network to cuda but they are running on cpu. Can you help?
def to_var(self, x):
        if torch.cuda.is_available():
            x = x.cuda()
        return Variable(x)

net = network.generator()
params = net.parameters()
optimizer = optim.Adam(params, lrG, [beta1, beta2], amsgrad=True)

if torch.cuda.is_available():
     net.cuda()

for i, data in enumerate(t_loader):

                source_img, target_img  = data[0], data[1]

                source_img = to_var(source_img)
                target_img = to_var(target_img)

                fake_generated_target = net(source_img)

                g_loss = torch.mean((fake_generated_target- 1) **2)

                optimizer.zero_grad()
                g_loss.backward()
                self.optimizer.step()```