Pretrained Googlenet

How to remove the inception5b layer of the pretrained googlenet model ? It will be highly appreciated if anyone helps as soon as possible .

You could try to replace it with an nn.Identity layer directly. Depending on the layer and in particular if the layer changes the size of the output activation compared to its input, this approach might not work since nn.Identity will just return the input directly without any manipulations.
In this case you would need to change more of the model architecture to account for the shape change in the activation.