Problem is setting old_conv_layer to None in prune_squeezenet_conv_layer
Please verify that
if ( int(_i)>2  and isinstance(module, torch.nn.modules.conv.Conv2d)):
                old_conv_layer = module
              

Is true or not.
Can you check this condition? I would recommend to initialize old_conv_layer to some base model (for non-specialized case)
Also, Can you add an assert for old_conv_layer to be non-none (good programming practice)