'BertForSequenceClassification' is not defined   'DUMMY_INPUTS' is not defined
Author: roccqqck
Pull request: no

transformers-2.1.1
https://github.com/huggingface/transformers#quick-tour-tf-20-training-and-pytorch-interoperability

i just copied and paste and run the code.

it showed 
```
NameError: name 'BertForSequenceClassification' is not defined
```

i can't even
```
from transformers import BertForSequenceClassification
```
```
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-27-7a027f32a339> in <module>
----> 1 from transformers import BertForSequenceClassification

ImportError: cannot import name 'BertForSequenceClassification' from 'transformers' 
```

Comments:
next time i 
```
import torch
```
it showed
```
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-14-71a5c3f94250> in <module>
----> 1 pytorch_model = BertForSequenceClassification.from_pretrained('model', from_tf=True)

~/miniconda3/envs/tfenv2/lib/python3.7/site-packages/transformers/modeling_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
    357                 try:
    358                     from transformers import load_tf2_checkpoint_in_pytorch_model
--> 359                     model = load_tf2_checkpoint_in_pytorch_model(model, resolved_archive_file, allow_missing_keys=True)
    360                 except ImportError as e:
    361                     logger.error("Loading a TensorFlow model in PyTorch, requires both PyTorch and TensorFlow to be installed. Please see "

~/miniconda3/envs/tfenv2/lib/python3.7/site-packages/transformers/modeling_tf_pytorch_utils.py in load_tf2_checkpoint_in_pytorch_model(pt_model, tf_checkpoint_path, tf_inputs, allow_missing_keys)
    199 
    200     if tf_inputs is None:
--> 201         tf_inputs = tf.constant(DUMMY_INPUTS)
    202 
    203     if tf_inputs is not None:

NameError: name 'DUMMY_INPUTS' is not defined
```

That's right, you can't import the PyTorch models if you don't have PyTorch installed in your environment. The `DUMMY_INPUTS` is a bug that was fixed with #1509. Could you please install it from source and let me know if you still have the error?

> Indeed, you can't import the PyTorch models if you don't have PyTorch installed in your environment. The `DUMMY_INPUTS` indeed is a bug that was fixed with #1509. Could you please install it from source and let me know if you still have the error?

does```pip install https://github.com/huggingface/transformers``` mean install from source?

I believe the correct way would be to specify it is a git url: 

`pip install git+https://github.com/huggingface/transformers.git`

> I believe the correct way would be to specify it is a git url:
> 
> `pip install git+https://github.com/huggingface/transformers.git`

it worked, but another issues showed up
```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-16-5f3cd63765b9> in <module>
      6 inputs_2 = tokenizer.encode_plus(sentence_0, sentence_2, add_special_tokens=True, return_tensors='pt')
      7 
----> 8 pred_1 = pytorch_model(**inputs_1)[0].argmax().item()
      9 pred_2 = pytorch_model(**inputs_2)[0].argmax().item()
     10 print("sentence_1 is", "a paraphrase" if pred_1 else "not a paraphrase", "of sentence_0")

~/miniconda3/envs/tfenv2/lib/python3.7/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    539             result = self._slow_forward(*input, **kwargs)
    540         else:
--> 541             result = self.forward(*input, **kwargs)
    542         for hook in self._forward_hooks.values():
    543             hook_result = hook(self, input, result)

TypeError: forward() got an unexpected keyword argument 'special_tokens_mask'
```

Indeed, this is a bug, it seems the readme is not up-to-date since we added the `special_tokens_mask` in 2.1. Thank you for reporting it!

If you add the two lines mentioned below, it should work:

```py
inputs_1 = tokenizer.encode_plus(sentence_0, sentence_1, add_special_tokens=True, return_tensors='pt')
inputs_2 = tokenizer.encode_plus(sentence_0, sentence_2, add_special_tokens=True, return_tensors='pt')

del inputs_1["special_tokens_mask"]  # <---- add this
del inputs_2["special_tokens_mask"]  # <---- add this

pred_1 = pytorch_model(**inputs_1)[0].argmax().item()
pred_2 = pytorch_model(**inputs_2)[0].argmax().item()
print("sentence_1 is", "a paraphrase" if pred_1 else "not a paraphrase", "of sentence_0")
print("sentence_2 is", "a paraphrase" if pred_2 else "not a paraphrase", "of sentence_0")
```

> Indeed, this is a bug, it seems the readme is not up-to-date since we added the `special_tokens_mask` in 2.1. Thank you for reporting it!
> 
> If you add the two lines mentioned below, it should work:
> 
> ```python
> inputs_1 = tokenizer.encode_plus(sentence_0, sentence_1, add_special_tokens=True, return_tensors='pt')
> inputs_2 = tokenizer.encode_plus(sentence_0, sentence_2, add_special_tokens=True, return_tensors='pt')
> 
> del inputs_1["special_tokens_mask"]  # <---- add this
> del inputs_2["special_tokens_mask"]  # <---- add this
> 
> pred_1 = pytorch_model(**inputs_1)[0].argmax().item()
> pred_2 = pytorch_model(**inputs_2)[0].argmax().item()
> print("sentence_1 is", "a paraphrase" if pred_1 else "not a paraphrase", "of sentence_0")
> print("sentence_2 is", "a paraphrase" if pred_2 else "not a paraphrase", "of sentence_0")
> ```

thanks it worked!!

We updated the README accordingly, feel free to open other issues if you encounter other bugs.

@LysandreJik 

i got a similar error when i run `run_tf_glue.py`.

```
...
Dataset glue downloaded and prepared to /root/tensorflow_datasets/glue/mrpc/0.0.2. Subsequent calls will reuse this data.
INFO:absl:Constructing tf.data.Dataset for split None, from /root/tensorflow_datasets/glue/mrpc/0.0.2
Train for 114 steps, validate for 6 steps
Epoch 1/2
114/114 [==============================] - 69s 601ms/step - loss: 0.5447 - accuracy: 0.7314 - val_loss: 0.4515 - val_accuracy: 0.7943
Epoch 2/2
114/114 [==============================] - 35s 306ms/step - loss: 0.2919 - accuracy: 0.8872 - val_loss: 0.4064 - val_accuracy: 0.8542
Traceback (most recent call last):
  File "run_tf_glue.py", line 51, in <module>
    pytorch_model = BertForSequenceClassification.from_pretrained('./save/', from_tf=True)
  File "/usr/local/lib/python3.6/dist-packages/transformers/modeling_utils.py", line 359, in from_pretrained
    model = load_tf2_checkpoint_in_pytorch_model(model, resolved_archive_file, allow_missing_keys=True)
  File "/usr/local/lib/python3.6/dist-packages/transformers/modeling_tf_pytorch_utils.py", line 201, in load_tf2_checkpoint_in_pytorch_model
    tf_inputs = tf.constant(DUMMY_INPUTS)
NameError: name 'DUMMY_INPUTS' is not defined
```

tf version : 2.0          ( via pip )
torch version : 1.2.0 (via pip )

Have you tried installing from source, as was mentioned in the comment before yourts? `pip install git+https://github.com/huggingface/transformers.git`

@LysandreJik 

i got another error ;;
```
$ pip3 install git+https://github.com/huggingface/transformers.git --upgrade
$ python run_tf_glue.py
...
Train for 114 steps, validate for 6 steps
Epoch 1/2
114/114 [==============================] - 60s 525ms/step - loss: 0.5817 - accuracy: 0.6911 - val_loss: 0.3961 - val_accuracy: 0.8229
Epoch 2/2
114/114 [==============================] - 34s 300ms/step - loss: 0.3505 - accuracy: 0.8460 - val_loss: 0.3403 - val_accuracy: 0.8516
Traceback (most recent call last):
  File "run_tf_glue.py", line 60, in <module>
    pred_1 = pytorch_model(**inputs_1)[0].argmax().item()
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 547, in __call__
    result = self.forward(*input, **kwargs)
TypeError: forward() got an unexpected keyword argument 'special_tokens_mask'
```

try importing 

from transformers.modeling_tf_bert import TFBertForSequenceClassification



> try importing
> 
> from transformers.modeling_tf_bert import TFBertForSequenceClassification

It worked! thanks.

Has  transformers.modeling_tf_bert been changed? I tried it and got:

> ModuleNotFoundError: No module named 'transformers.modeling_tf_bert'

even though I've successfully imported transformers

what is the proper call to import BertForSequenceClassification?

To import `BertForSequenceClassification` (you need to have PyTorch installed), 

```py
from transformers import BertForSequenceClassification
```

To import `TFBertForSequenceClassification` (you need to have TensorFlow installed):

```py
from transformers import TFBertForSequenceClassification
```