What exactly are you trying to achieve?
Are you trying to have a sequential model where some layers are custom?
Or will the whole model not use sequential?
What might be interesting is to look at how torchviz gets the names.
What I e.g. found is the method get_var_name in dot.py
You then have to make sure that the names you want are returned by the functions (or stored in the variables) that torchviz is using.