I just want to make sure that what I’m doing is correct because I could not find the same question asked before, but if I structure my model as below, with the encoder as a separate module used within the autoencoder module:
class Encoder(nn.Module):
    def __init__(self):
        super(Encoder, self).__init__()

        self.encoder = nn.Sequential(
            nn.Linear(136, 136),
            nn.ReLU(),
            nn.Linear(136, 1),
        )

    def forward(self, x):
        return self.encoder(x)


class Autoencoder(nn.Module):
    def __init__(self, encoder_model):
        super(Autoencoder, self).__init__()

        self.encoder = encoder_model
        self.decoder = nn.Sequential(
            nn.Linear(1, 136),
            nn.ReLU(),
            nn.Linear(136, 136),
        )

    def forward(self, x):
        encoded = self.encoder(x)
        return self.decoder(encoded)

And then set up a model with:
encoder_model = Encoder().to(device)

unsupervised_model = Autoencoder(encoder_model).to(device)
unsupervised_criterion = nn.MSELoss()
unsupervised_optimizer = torch.optim.Adam(unsupervised_model.parameters(), lr=args.learning_rate)

When I perform unsupervised_optimizer.step() the encoder part of the autoencoder will be trained as well right, because that should be part of the computational graph?