If you are using other libraries, such as numpy or PIL, you would detach the tensor from the computation graph since Autograd isn’t able to track these operations. This would mean that previous operations are not attached to the newly created tensors in:
Avg_color = [torch.tensor(x,dtype=float,requires_grad=False) for x in styleGAN_transformedimage]

and thus no parameters used in the previous operation will get any gradients.
You would have to either use PyTorch operations or write custom autograd.Functions as described here 1.