Could you check, if all passed arguments are nn.Module objects, i.e. denseBlocks, links, and classifier?
It’s unclear from the error message which module is raising this issue and the code looks generally alright.
Wrapping the modules in nn.Sequential inside the forward is unusual, but shouldn’t change the device.
Feel free to add the missing module definitions in case you get stuck, so that we can help debugging.