Your current code snippet recreates the nn.LSTMCell and nn.Linear modules in each forward pass randomly and doesn’t register them.
The proper way is to initialize submodules in the __init__ method and use them in the forward.