I was following this method
(Dynamic parameter declaration in forward function 3) to dynamically assign parameters in  forward  function.
However, my parameter is not just one single weight tensor but it is  nn.Sequential .
When I implement below:
class MyModule(nn.Module):
    def __init__(self):
        # you need to register the parameter names earlier
        self.register_parameter('W_di', None)

    def forward(self, input):
        if self.W_di is None:
            self.W_di = nn.Sequential(
                nn.Linear(mL_n * 2, 1024),
                nn.ReLU(),
                nn.Linear(1024, self.hS)).to(device)

I get the following error.
 TypeError: cannot assign 'torch.nn.modules.container.Sequential' as parameter 'W_di' (torch.nn.Parameter or None expected)

Is there any way that I can register  nn.Sequential  as a whole param? Thanks!