You are detaching the tensors from the computation graph by recreating new tensors in particular here:
input_style = input_style.detach().cpu().numpy()
...
self.loss = torch.tensor(self.loss, requires_grad=False, dtype=torch.float).to(device)
input_style = torch.tensor(input_style, dtype=torch.float).to(device)

Try to use the output of the functions directly without recreating tensors.
If you need to change the data type, use .float() or to().