do you mean something like this,
model = nn.ModuleList([nn.Linear(10, 10), nn.Linear(10, 10), nn.ReLU()])
model

ModuleList(
  (0): Linear(in_features=10, out_features=10, bias=True)
  (1): Linear(in_features=10, out_features=10, bias=True)
  (2): ReLU()
)

x = torch.randint(0, len(model), (2,)); x

tensor([2, 0])
for i in x:
  model[i] = nn.Identity()

model

ModuleList(
  (0): Identity()
  (1): Linear(in_features=10, out_features=10, bias=True)
  (2): Identity()
)