Your code works fine:
class BranchRoutingModule(nn.Module):
  def __init__(self, in_channels=512, epsilon=1e-12):
    super(BranchRoutingModule, self).__init__()

    self.conv1 = nn.Conv2d(in_channels=in_channels, out_channels=in_channels, kernel_size=1)
    self.l2norm = lambda x: torch.nn.functional.normalize(x, dim=1)
    self.fc = nn.Linear(in_channels, 1)
    self.avgpool = nn.AdaptiveAvgPool2d((1, 1)) # size 1x1
    self.signedsqrt = lambda x: torch.sign(x) * torch.sqrt(torch.sign(x) * x + epsilon) 
    self.sigmoid = nn.Sigmoid()

  def forward(self, x):
    feature = self.conv1(x)
    feature = self.avgpool(feature)
    feature = self.signedsqrt(feature)
    feature = self.l2norm(feature)
    feature = feature.view(feature.size(0), -1)
    out = self.fc(feature)
    out = self.sigmoid(out)
    return out

class MyModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.structure = nn.ModuleList([nn.ModuleList([BranchRoutingModule() for j in range(10)]) for  i in range(5)])
        
    def forward(self, x):
        outs = []
        for modules in self.structure:
            for m in modules:
                out = m(x)
                print(out.shape)
                outs.append(out)
                
        outs = torch.cat(outs, dim=1)
        return outs
        
    
model = MyModel().cuda()
# make sure parameters are on the device
for name, param in model.named_parameters():
    print('{}, {}'.format(name, param.device))
x = torch.randn(2, 512, 24, 24).cuda()
out = model(x)
print(out.shape)
# > torch.Size([2, 50])

All parameters are pushed to the device and no errors are raised.