You could just set the BatchNorm layer into eval mode, either by indexing it directly or recursively.
Here is a small example for the latter approach:
class MyModel(nn.Module):
    def __init__(self):
        super(MyModel, self).__init__()
        self.conv1 = nn.Conv2d(1, 6, 3, 1, 1)
        self.bn1 = nn.BatchNorm2d(6)
        self.fc = nn.Linear(6*24*24, 2)
        
    def forward(self, x):
        x = F.relu(self.conv1(x))
        x = self.bn1(x)
        x = x.view(x.size(0), -1)
        x = self.fc(x)
        return x


def set_bn_eval(m):
    if isinstance(m, nn.modules.batchnorm._BatchNorm):
        m.eval()


def set_bn_train(m):
    if isinstance(m, nn.modules.batchnorm._BatchNorm):
        m.train()


model = MyModel()
model.apply(set_bn_eval)