If you do not have nn.Identity, just define it.
import torch.nn as nn
from torchvision.models import vgg19

class Identity(nn.Module):
    def __init__(self, *args, **kwargs):
        super().__init__()
    def forward(self, x):
        return x

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