Completly freezed submodule

How can I store submodule but in completly freezed way?

Consider the example:

class PerceptualLoss(nn.Module):
    def __init__(self, vgg):
        super().__init__()
        self.vgg = vgg

In this example parameters of vgg will be presented in parameters in PerceptualLoss wich is incorrect e.g. while using with Optimizer. But at the same time methods like .cuda(), .cpu(), .to() and others should track parameters of vgg. Is that achivable?

set the requires_grad attribute of vgg's parameters to False. The parameters will still be presented in the parameters of PerceptualLoss, but they won’t be optimized:

for param in self.vgg.parameters():
    param.requires_grad = False