My code for reference:
class Network(torch.nn.Module):
    def __init__(self, layer, hid):
        super(Network, self).__init__()
        self.layer = layer
        
        self.short = nn.Sequential(
            nn.Linear(2, hid), # Hidden Layer 1
            nn.Tanh(),
            nn.Linear(hid, 2), # Output Layer
            nn.Sigmoid()
        )
        self.long = nn.Sequential(
            nn.Linear(1, hid), # Hidden Layer 1
            nn.Tanh(),
            nn.Linear(hid, hid), # Hidden Layer 2
            nn.Tanh(),
            nn.Linear(hid, 2), # Output Layer
            nn.Sigmoid()
        )
        

    def forward(self, input):
        x = input
        x = x.view(x.size(0), -1)
        
        if (self.layer == 1):
            output = self.short(x)
            return output
        else:
            output = self.long(x)
            return output