Your conditions should prevent this.
Did you add an else into your pruning code?
Currently you check the Modules for nn.Conv2d, nn.BatchNorm2d and nn.Linear, so I don’t understand, how the nn.ReLU can get into the pruning part.