In the forward method:
l = self.transfer(x.shape[1], self.perceptron[0].in_features)
x = self.perceptron(l(x))

what you are doing is creating a new layer at each step … So this layer l cannot learn, since it is discarded and randomly reinitialized at each step.
The thing is, there is no variable-size nn.Linear layer!
Because this layer has a fixed number of parameters which are learned, and it would not be logical to remove some, or add new parameters at each step during training.
Is your input tensor x of variable size ?