Hi,
You can freeze BN trainable parameters with something like:
for m in model.modules():
    if isinstance(m, nn.BatchNorm2d):
        m.weight.requires_grad_(False)
        m.bias.requires_grad_(False)

This should be done once before training starts. Also don’t forget to pass to the optimiser ONLY the trainable params.
And then you can freeze BN statistics at the beginning of each epoch (after you call model.train()) with:
for m in model.modules():
    if isinstance(m, nn.BatchNorm2d):
        m.eval()

Hope this helps!