Unable to call .from_pretrained() for Roberta Model
### Defined a class that inherits from RobertaPretrainedModel

This class is defined to concat image and text embedding

    class XLMRobertaWithImageConcatenationMultiOutputClassifier(RobertaPreTrainedModel):

        def __init__(self,  config_bert , num_labels):

          super(XLMRobertaWithImageConcatenationMultiOutputClassifier, self).__init__(config_bert)
          self.num_labels = num_labels
          self.num_another_labels = num_another_labels
          self.bert = RobertaModel(config_bert)
          self.backbone = models.resnet50(pretrained = False)        
          num_features = self.backbone.fc.in_features
          self.img_hidden_size = 512
          self.pre_classify_hidden = 512        
          self.pre_classify_fc = torch.nn.Linear(config_bert.hidden_size + self.img_hidden_size, self.pre_classify_hidden)
          self.classifier = torch.nn.Linear(self.pre_classify_hidden, num_labels)
          self.apply(self._init_weights)



### Trying to call XLMRobertaWithImageConcatenationMultiOutputClassifier from pretrained

        model = XLMRobertaWithImageConcatenationMultiOutputClassifier.from_pretrained( 'roberta-base', num_labels = NUM_CLASSES)

### Error
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-22-d0dbf641e2da> in <module>
---> 17 model = XLMRobertaWithImageConcatenationMultiOutputClassifier.from_pretrained('roberta-base', num_labels=NUM_CLASSES)

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/transformers/modeling_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
   1323         else:
   1324             with no_init_weights(_enable=_fast_init):
-> 1325                 model = cls(config, *model_args, **model_kwargs)
   1326 
   1327         if from_pt:

TypeError: __init__() missing 1 required positional argument: 'num_labels'

Is there something I am missing? Despite giving num_labels it still asks for that parameter? Any idea or help would be highly appreciated.

Maybe you can try specifying `num_labels` as a positional argument instead of a keyword argument, like the following:

```
model = XLMRobertaWithImageConcatenationMultiOutputClassifier.from_pretrained( 'roberta-base', NUM_CLASSES)
```

<|||||>Hi!

@qqaatw is right, model_args to `init` should be passed as positional arguments instead as `kwargs`, the `kwargs` are passed to `config` init.

Another way to do this would be to add `num_labels` to configuration and then access that as `config.num_labels` in the model. Then you could pass it as `kwargs` to `from_pretarained`.<|||||>@qqaatw you are absolutely correct about not giving num_labels as keyword argument! I finally implemented like @patil-suraj suggested to fetch num_labels and another_num_labels from a configuration.