Torchserve process

I’m a little confused about the torchserve process, even after successfully setting up the densenet example. Specifically, the archiving of the model.

In all of the examples, the model file has to:
subclass an nn module
implement a forward function

the pth file has to be a trained, serialized model of the type classified above.

Here’s my confusion.
using this example: serve/ at master · pytorch/serve · GitHub

First of all, the model file included with the densenet example does not implement a forward function.
I’m guessing its inherited somewhere, but if that’s the case, why complicate the example for noobs like myself?

Second, what does the forward function actually need to contain? Again. I’ve seen and read the references in the pytorch and torchserve tutorials:
Is the forward function just telling it where the input goes, and what the output looks like? why isn’t it defined per layer?

What would it look like for an lstm with several timesteps in its sequence? (you have no lstm pytorch/torchserve examples in this tutorial. Just a simple “how to lstm” using pre-ordained weights)

Second, for the trained model, other than performing training as one would for any other type of model, and writing out the state dict, are there any other specifications that have to be followed?

So I guess i’m confused about both the process, and the torchserve’s actual requirements. Unfortunately, the tutorials just caused more confusion. I’ve looked at probably 6 or 7 others, and they all do it a bit differently, and none of them specifically follow the archiver’s recommendation, or structure.

Is the process (for an lstm)
train the model using the data i have
write out a state dict representing the trained model
include the file that defines init and a forward function (still a little lost on the forward function)
archive the whole thing together in a .mar file
torchserve stuff (i’ve got that handled)

If possible, could one provide a detailed example of exactly what the archiver wants, what a forward function actually does (conceptually, from a torchserve perspective) and how this all fits together.

Thank you very much for your time