nn.AvgPool2d with a kernel size of 1 acts like an identity layer, your model basically got rid of the pooling layer.
Alternatively, you could just define the resnet.avgpool as a “real” custom Identity layer:
class Identity(nn.Module):
    def __init__(self):
        super(Identity, self).__init__()
        
    def forward(self, x):
        return x

model.avgpool = Identity()
model.fc = nn.Linear(512*7*7, nb_classes)

Both approaches will yield the same result.