import torch.nn as nn
from torchvision.models import vgg19

net = vgg19(pretrained=True)
net.avgpool = nn.Identity()

But if you remove the average pooling layer, your output before classifier must have shape (N, 512, 7, 7), or you have to change the in_features of net.classifier[0] (the Linear layer).