NameError: name 'DUMMY_INPUTS' is not defined - From TF to PyTorch
Author: RubensZimbres
Pull request: no

## 🐛 Bug

I'm using TFBertForSequenceClassification, Tensorflow 2.0.0b0, PyTorch is up-to-date and the code from Hugging Face README.md:

```
import tensorflow as tf
import tensorflow_datasets
from transformers import *

tf.compat.v1.enable_eager_execution()

tokenizer = BertTokenizer.from_pretrained('bert-base-cased')
model = TFBertForSequenceClassification.from_pretrained('bert-base-cased')
data = tensorflow_datasets.load('glue/mrpc')

train_dataset = glue_convert_examples_to_features(data['train'], tokenizer, max_length=128, task='mrpc')
valid_dataset = glue_convert_examples_to_features(data['validation'], tokenizer, max_length=128, task='mrpc')
train_dataset = train_dataset.shuffle(100).batch(32).repeat(2)
valid_dataset = valid_dataset.batch(64)

optimizer = tf.keras.optimizers.Adam(learning_rate=3e-5, epsilon=1e-08, clipnorm=1.0)
loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)
metric = tf.keras.metrics.SparseCategoricalAccuracy('accuracy')
model.compile(optimizer=optimizer, loss=loss, metrics=[metric])

history = model.fit(train_dataset, epochs=2, steps_per_epoch=115,
                    validation_data=valid_dataset, validation_steps=7)

model.save_pretrained('/home/rubens_gmail_com/tf')
```
The model trains properly, but after weights are saved as `.h5` and I try to load to `BertForSequenceClassification.from_pretrained`, the following error shows up:

```
pytorch_model = BertForSequenceClassification.from_pretrained('/home/rubens_gmail_com/tf',from_tf=True)


NameError                                 Traceback (most recent call last)
<ipython-input-25-7a878059a298> in <module>
      1 pytorch_model = BertForSequenceClassification.from_pretrained('/home/rubens_gmail_com/tf', 
----> 2                                                               from_tf=True)

~/.local/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 "

~/.local/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
```

If I run:
```
pytorch_model = BertForSequenceClassification.from_pretrained('/home/rubens_gmail_com/tf/tf_model.h5',from_tf=True)
```
I get:

```
UnicodeDecodeError                        Traceback (most recent call last)
<ipython-input-35-4146e5f25140> in <module>
----> 1 pytorch_model = BertForSequenceClassification.from_pretrained('/home/rubens_gmail_com/tf/tf_model.h5',from_tf=True)

~/.local/lib/python3.7/site-packages/transformers/modeling_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
    285                 cache_dir=cache_dir, return_unused_kwargs=True,
    286                 force_download=force_download,
--> 287                 **kwargs
    288             )
    289         else:

~/.local/lib/python3.7/site-packages/transformers/configuration_utils.py in from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
    152 
    153         # Load config
--> 154         config = cls.from_json_file(resolved_config_file)
    155 
    156         if hasattr(config, 'pruned_heads'):

~/.local/lib/python3.7/site-packages/transformers/configuration_utils.py in from_json_file(cls, json_file)
    184         """Constructs a `BertConfig` from a json file of parameters."""
    185         with open(json_file, "r", encoding='utf-8') as reader:
--> 186             text = reader.read()
    187         return cls.from_dict(json.loads(text))
    188 

/opt/anaconda3/lib/python3.7/codecs.py in decode(self, input, final)
    320         # decode input (taking the buffer into account)
    321         data = self.buffer + input
--> 322         (result, consumed) = self._buffer_decode(data, self.errors, final)
    323         # keep undecoded input until the next call
    324         self.buffer = data[consumed:]

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte

```


I'm using Python 3.7.4, 8 x V100 GPU, Anaconda environment on a Debian on GCP. Any ideas on how to overcome this issue ?

Comments:
Hi! I believe this is a bug that was fixed on master. Could you try and install from source and tell me if it fixes your issue?

You can do so with the following command in your python environment:

```
pip install git+https://github.com/huggingface/transformers
```

@LysandreJik Thanks for the hint. I used a workaround. I installed `transformers` using:

```
conda install -c conda-forge transformers
```

In Python 3.7.4, then I added `DUMMY_INPUTS = [[7, 6, 0, 0, 1], [1, 2, 3, 0, 0], [0, 0, 0, 4, 5]]` after variable `logger` in  `/opt/anaconda3/lib/python3.7/site-packages/transformers/modeling_tf_utils.py`, because it was missing.

It was interesting, because in GCP, transformers were not showing in `python3` , only in `sudo python3`

@LysandreJik I updated the install from source but ran into the same issue. The "solution" was again as @RubensZimbres mentions: adding `DUMMY_INPUTS = [[7, 6, 0, 0, 1], [1, 2, 3, 0, 0], [0, 0, 0, 4, 5]]` after variable `logger`, however I needed it changed in `/opt/anaconda3/lib/python3.7/site-packages/transformers/modeling_tf_pytorch_utils.py`.


I created a Pull Request at: https://github.com/huggingface/transformers/pull/1847

Can't reproduce on master and the latest release (2.2.1).
Feel free to reopen if the issue is still there.