I’ve got the same problem. I try some of the tips suggested here, but the problem persists.
class VTransformer(nn.Module):
  def __init__(self, type = 'vit_base_patch16_224', pretrained = True, K = 2):
    super(VTransformer, self).__init__()

    model = timm.create_model(type, pretrained = pretrained)

    self.features = nn.Sequential(*list(model.children())[:-1])
    self.numfeat = list(model.children())[-1].in_features

    #self.numfeat = self.features[-1].in_features
    if pretrained:
      # freeze  weights
      for param in self.features.parameters():
        param.requires_grad = False

    self.classifier = nn.Sequential(
        nn.Linear(self.numfeat, K),
    )
    #self.classifier = nn.Sequential(
    #    nn.Dropout(0.2),
    #    nn.Linear(128 * 3 * 3, 1024),
    #    nn.ReLU(),
    #    nn.Dropout(0.2),
    #    nn.Linear(1024, K)
    #)

  def forward(self, x):
    print(x.size())
    out = self.features(x)
    out = self.classifier(out)
    print(out.size())
    return out

modelRGB = VTransformer()
modelRGB.eval()
pred = modelRGB(torch.randn(1,3,224,224))

torch.Size([1, 3, 224, 224])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-73-28d07edefb6c> in <module>()
      2 #print(modelRGB)
      3 modelRGB.eval()
----> 4 pred = modelRGB(torch.randn(1,3,224,224))

4 frames
/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
    725             result = self._slow_forward(*input, **kwargs)
    726         else:
--> 727             result = self.forward(*input, **kwargs)
    728         for hook in itertools.chain(
    729                 _global_forward_hooks.values(),

TypeError: forward() takes 1 positional argument but 2 were given