No, what you can do is
def forward(self, x):
    x = self.L1(x)
    y = self.L2(x)
    return x,y

By design, pytorch modules hold the parameters, but do not “contain the computation”.
Best regards
Thomas