if I run
model = torchvision.models.densenet201(pretrained=True)

model.classifier = torch.nn.Linear(1920, 22, bias=True)

x = torch.ones((1, 3, 224, 224))

out = model(x)

everything goes well. It’s torchvisions densnet and not the one you linked, but that should not matter.
I am not sure if the problem is really on the forward pass. You should run your code in sections and check where exactly the error happens. Are you maybe doing other operations on your tensors before or after passing through your model?
Try to first identify where exactly the mismatch is and then try to look at the shapes of the tensors involved (using something like print(x.shape) maybe)