Yes, you just use an if statement in your forward pass:
# Create self.layers as a nn.ModuleList
def forward(self, input, input_type):
    out = input
    if input_type == 0:
      for i in range(10):
        out = self.layers[i](out)
    else:
      for i in range(8):
        out = self.layers[i](out)
    return out