[TorchScript] Received several warning during Summarization model conversion
Author: lanking520
Pull request: no

## Environment info
Using Transformers 4.0.1 and PyTorch 1.6.0.

```pytorch
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import torch

tokenizer = AutoTokenizer.from_pretrained("sshleifer/distilbart-cnn-6-6")

model = AutoModelForSeq2SeqLM.from_pretrained("sshleifer/distilbart-cnn-6-6")

# model = BartModel.from_pretrained("sshleifer/bart-tiny-random")
input_ids = decoder_input_ids = torch.tensor([19 * [1] + [model.config.eos_token_id]])
traced_model = torch.jit.trace(model, (input_ids, decoder_input_ids), strict=False)

traced_model.save("distilbart.pt")
```

I have to disable the strict checking in order to pass. (Error message without disable the strict flag):

```
RuntimeError: Encountering a dict at the output of the tracer might cause the trace to be incorrect, this is only valid if the container structure does not change based on the module's inputs. Consider using a constant container instead (e.g. for `list`, use a `tuple` instead. for `dict`, use a `NamedTuple` instead). If you absolutely need this and know the side effects, pass strict=False to trace() to allow this behavior.
```

Here is the warning messages:
```
/Users/qingla/PycharmProjects/pytorch/venv/lib/python3.7/site-packages/transformers/models/bart/modeling_bart.py:232: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if not padding_mask.any():
/Users/qingla/PycharmProjects/pytorch/venv/lib/python3.7/site-packages/transformers/models/bart/modeling_bart.py:175: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if decoder_padding_mask is not None and decoder_padding_mask.shape[1] > 1:
/Users/qingla/PycharmProjects/pytorch/venv/lib/python3.7/site-packages/transformers/models/bart/modeling_bart.py:716: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  assert key_padding_mask is None or key_padding_mask.shape == (bsz, src_len)
/Users/qingla/PycharmProjects/pytorch/venv/lib/python3.7/site-packages/transformers/models/bart/modeling_bart.py:718: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  assert attn_weights.size() == (bsz * self.num_heads, tgt_len, src_len)
/Users/qingla/PycharmProjects/pytorch/venv/lib/python3.7/site-packages/transformers/models/bart/modeling_bart.py:736: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  assert attn_output.size() == (bsz * self.num_heads, tgt_len, self.head_dim)
/Users/qingla/PycharmProjects/pytorch/venv/lib/python3.7/site-packages/transformers/models/bart/modeling_bart.py:287: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if torch.isinf(x).any() or torch.isnan(x).any():
```

If these warning are indicated correctly, them the model I traced is highly tied to the dummy input I provided which would bring inaccurate inference result... Any thoughts on how to improve it? @sshleifer Thanks!

Comments:
Have you tried removing the `strict=False`, and instead specify `return_dict=False` when you initialize the model with `from_pretrained`? Can you let me know if this fixes your issue?

> Have you tried removing the `strict=False`, and instead specify `return_dict=False` when you initialize the model with `from_pretrained`? Can you let me know if this fixes your issue?

Thanks. It seemed the error message is gone. However, I still receive the warning messages. Is there anyway I can modify the script and make it work without warning?

Usually these do not impact the result, as they are python values that do not change over time. Have you seen an error in prediction?

@LysandreJik Sounds good. Haven't seen anything wrong yet. :)

I got this error too, when converting .safetensors to TorchScript. It's a model called ced( https://github.com/jimbozhang/hf_transformers_custom_model_ced.git )

```
    device = torch.device("cpu")
    example_input = torch.rand(1, 64, 301).to(device)
    model.eval()  
    traced_script_module = torch.jit.trace(model, example_input)
    traced_script_module.save("ced_tiny_trace_torch_script.pt")
    print('TorchScript trace saved')
```


```
Traceback (most recent call last):
  File "/Users/luis/PycharmProjects/hf_transformers_custom_model_ced/convert_pytorch_mobile.py", line 72, in <module>
    convert2(model)
  File "/Users/luis/PycharmProjects/hf_transformers_custom_model_ced/convert_pytorch_mobile.py", line 44, in convert2
    traced_script_module = torch.jit.trace(model, example_input)
  File "/Users/luis/PycharmProjects/hf_transformers_custom_model_ced/venv/lib/python3.9/site-packages/torch/jit/_trace.py", line 794, in trace
    return trace_module(
  File "/Users/luis/PycharmProjects/hf_transformers_custom_model_ced/venv/lib/python3.9/site-packages/torch/jit/_trace.py", line 1056, in trace_module
    module._c._create_method_from_trace(
RuntimeError: Encountering a dict at the output of the tracer might cause the trace to be incorrect, this is only valid if the container structure does not change based on the module's inputs. Consider using a constant container instead (e.g. for `list`, use a `tuple` instead. for `dict`, use a `NamedTuple` instead). If you absolutely need this and know the side effects, pass strict=False to trace() to allow this behavior.

```