The gradient calculation is independent from model.train()/eval().
train() and eval() will change the behavior of some modules, such as dropout and batch norm layers.
The gradient calculation (frozen parameters or not) won’t be changed.
So even if you wrap the code in a with torch.no_grad() block, which will disable the gradient calculation, the batch norm stats will be updated, if the modules in still in training mode.