I don’t know what exactly you are trying to do, but you can access the modules (layers) via their name, e.g.:
class MyModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc = nn.Linear(1, 1)
        
    def forward(self, x):
        x = self.fc(x)
        return x

model = MyModel()
print(model.fc)
> Linear(in_features=1, out_features=1, bias=True)
model.fc = nn.Conv2d(3, 6, 3, 1, 1)
print(model.fc)
> Conv2d(3, 6, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))