The input to a nn.Module is a Variable of shape batch_size * feature_size.
Let’s say you have a nn.Linear(3,5) module. This module take as input a tensor of shape batch_size * 3. So the definition of the module is independent of the batch size. Does this answer your question?
PS. That being said the batch_size has to be at least 1