LongformerForQuestionAnswering sample code error
Author: prince14322
Pull request: no

## Environment info
- `transformers` version: 2.11.0
- Platform: Linux-4.19.112+-x86_64-with-debian-buster-sid
- Python version: 3.7.6
- PyTorch version (GPU?): 1.5.1 (False)
- Tensorflow version (GPU?): 2.3.0 (False)
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No


 Longformer/Reformer: @patrickvonplaten

## Information

Model I am using LongformerForQuestionAnswering
The problem arises when using:
[https://huggingface.co/transformers/v2.11.0/model_doc/longformer.html#longformerforquestionanswering](url)


## To reproduce

Steps to reproduce the behavior:

1. I ran the following code on Kaggle kernel

from transformers import LongformerTokenizer, LongformerForQuestionAnswering
import torch
tokenizer = LongformerTokenizer.from_pretrained("allenai/longformer-large-4096-finetuned-triviaqa")
model = LongformerForQuestionAnswering.from_pretrained("allenai/longformer-large-4096-finetuned-triviaqa", return_dict=True)
question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"
encoding = tokenizer(question, text, return_tensors="pt")
input_ids = encoding["input_ids"]
attention_mask = encoding["attention_mask"]
outputs = model(input_ids, attention_mask=attention_mask)
start_logits = outputs.start_logits
end_logits = outputs.end_logits
all_tokens = tokenizer.convert_ids_to_tokens(input_ids[0].tolist())
answer_tokens = all_tokens[torch.argmax(start_logits) :torch.argmax(end_logits)+1]
answer = tokenizer.decode(tokenizer.convert_tokens_to_ids(answer_tokens)) # remove space prepending space token

**Following error occurred**

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-70f3a4bf4161> in <module>
      2 import torch
      3 tokenizer = LongformerTokenizer.from_pretrained("allenai/longformer-large-4096-finetuned-triviaqa")
----> 4 model = LongformerForQuestionAnswering.from_pretrained("allenai/longformer-large-4096-finetuned-triviaqa", return_dict=True)
      5 question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"
      6 encoding = tokenizer(question, text, return_tensors="pt")

/opt/conda/lib/python3.7/site-packages/transformers/modeling_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
    653 
    654         # Instantiate model.
--> 655         model = cls(config, *model_args, **model_kwargs)
    656 
    657         if state_dict is None and not from_tf:

TypeError: __init__() got an unexpected keyword argument 'return_dict'



> and after doing the following changes:

 _encoding = tokenizer(question, text, return_tensors="pt")  ->   encoding = tokenizer(question, text)_

the following error occured

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-54aabf4ba7c0> in <module>
      1 question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"
----> 2 encoding = tokenizer(question, text, return_tensors="pt")

TypeError: 'LongformerTokenizer' object is not callable




Comments:
`tokenizer` is not a callable in v.2.11.0, which is why you are getting this error. Also the example that you posted is from stable docs not from 2.11.0, upgrading to latest stable version should resolve the issue.

@patil-suraj
Sorry for asking this naive ques but how to upgrade to latest stable version?
and
What about the first error?
TypeError: init() got an unexpected keyword argument 'return_dict'

Can you please point to some reference or any link?

Upgrading to latest version should also resolve the first issue. To upgrade

`pip install -U transformers`

Thank You. It worked.