So here’s what I discovered.
        for param in self.E.parameters():
            param.requires_grad = False

works, except that even though I run E.eval() before passing it into M, somehow it gets into state E.train() during M’s training, and thus dropout is enabled. If I run E.eval() every time before I call E to do evaluation, it is fine. I don’t really understand why this is, if someone can explain.