My problem is best illustrated with an example.
class Generator(nn.Module):
    def __init__(self):
        super(Generator, self).__init__()

        self.l1 = nn.Sequential(
            nn.Linear(1200, 1)
        )

    def forward(self, z):
        zh = self.l1(z)
        return x

works. However,
class Generator(nn.Module):
    def __init__(self):
        super(Generator, self).__init__()

        def l1x(somenumber):
            return nn.Sequential(
                nn.Linear(somenumber, 1)
            )
        self.l1 = l1x

    def forward(self, z):
        zh = self.l1x(1200)(x)
        return x

gives

Expected object of type torch.FloatTensor but found type torch.cuda.FloatTensor

when I use cuda. If I edit self.l1x(1200).cuda()(x) this will work too but I already made my generator object cuda() after I initialized the object. Hence I want it to work like everything else without extra steps.
What am I doing wrong?