Understanding AdderNet model construction coding

What is the purpose of the following code snippet in AdderNet ?

    def _make_layer(self, block, planes, blocks, stride=1):
        downsample = None
        if stride != 1 or self.inplanes != planes * block.expansion:
            downsample = nn.Sequential(
                adder.adder2d(self.inplanes, planes * block.expansion, kernel_size=1, stride=stride, bias=False),
                nn.BatchNorm2d(planes * block.expansion)
            )

        layers = []
        layers.append(block(inplanes = self.inplanes, planes = planes, stride = stride, downsample = downsample))
        self.inplanes = planes * block.expansion
        for _ in range(1, blocks):
            layers.append(block(inplanes = self.inplanes, planes = planes))

        return nn.Sequential(*layers)

This code snippet seems to be similar to the _make_layer method used in the resnet creation.

It’s accepting a few arguments, e.g. the desired block to use in these layers, and creates an nn.Sequential container out of these arguments.

In a torchvision resnet, you could print one of these blocks e.g. via print(model.layer4) to see which submodules were created.