[Examples] Added support for test-file in QA examples with no trainer
Author: bhadreshpsavani
Pull request: yes

# What does this PR do?

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [x] this was discuss in another [PR](https://github.com/huggingface/transformers/pull/11380#issuecomment-824930263)
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/master/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/master/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?

## Who can review?
@sgugger @stas00

Comments:
One More thing i want to mention is below code,
https://github.com/huggingface/transformers/blob/ad1f7bef13f03287af00f819605d696138a5e6ec/examples/pytorch/question-answering/run_qa_no_trainer.py#L543-L547
i changed to
```python
    eval_dataset.set_format(type="torch", columns=["attention_mask", "input_ids"])
    eval_dataloader = DataLoader(eval_dataset, collate_fn=data_collator, batch_size=args.per_device_eval_batch_size)

    if args.do_predict:
        predict_dataset.set_format(type="torch", columns=["attention_mask", "input_ids"])
```
because somehow for local files `token_type_ids` was giving an error. at below line
https://github.com/huggingface/transformers/blob/ad1f7bef13f03287af00f819605d696138a5e6ec/examples/pytorch/question-answering/run_qa_no_trainer.py#L543
For the dataset, it was working fine.
When I remove the `token_type_ids` script run successfully for both part!

In the Readme.md of question-answering, i think there is a typo! in below line
```
export TASK_NAME=mrpc
```

Hi @sgugger,
I have removed two columns since the eval_dataset  is having following features,
```
['attention_mask', 'example_id', 'input_ids', 'offset_mapping']
```
and dataloader also had issue with `offset_mapping`

Hi @sgugger,
There is an error in the post_processing of `examples/pytorch/question-answering/run_qa_beam_search_no_trainer.py`
```
Traceback (most recent call last):
  File "transformers/examples/pytorch/question-answering/run_qa_beam_search_no_trainer.py", line 815, in <module>
    main()
  File "transformers/examples/pytorch/question-answering/run_qa_beam_search_no_trainer.py", line 746, in main
    prediction = post_processing_function(eval_examples, eval_dataset, outputs_numpy)
  File "transformers/examples/pytorch/question-answering/run_qa_beam_search_no_trainer.py", line 577, in post_processing_function
    prefix=stage,
  File "/content/transformers/examples/pytorch/question-answering/utils_qa.py", line 323, in postprocess_qa_predictions_with_beam_search
    feature_null_score = cls_logits[feature_index]
IndexError: index 1 is out of bounds for dimension 0 with size 1
100% 9/9 [01:42<00:00, 11.35s/it]
```
It can be reproduced using this [colab](https://github.com/bhadreshpsavani/UnderstandingNLP/blob/master/PostProcessingErrorInQAWithBeamSearchWithNoTrainer.ipynb),

When I checked i found that `cls_logits` is coming like `tensor([-0.3511])` instead it should have length equal to number of samples (Five in this case) like `[-0.45879194 -0.46871808 -0.3622135  -0.4451167  -0.4400767 ]` 


Hi @sgugger,
Please let me know if the above changes don't seem fine.
I think there was a typo earlier it should be like this. Please correct me if I am wrong! 

Yes, thanks for catching that last problem! I believe the last thing to do is to remove the lines that reset the columns of the `eval_dataset` and `test_dataset` in the post processing ([here](https://github.com/huggingface/transformers/blob/1b0af5f4ed01c227179589722cd658d68f90be6a/examples/pytorch/question-answering/run_qa_beam_search_no_trainer.py#L736) and [there](https://github.com/huggingface/transformers/blob/1b0af5f4ed01c227179589722cd658d68f90be6a/examples/pytorch/question-answering/run_qa_beam_search_no_trainer.py#L794) in run_qa_beam_search_no_trainer, but they also are in run_qa_no_trainer)

Sure @sgugger,
I forgot that, Thanks!

Thanks a lot for your work on this!

Thank you, @sgugger, for catching parts I missed in my review! Much appreciated!

Hi!
There is a typo in line 794 in run_qa_no_trainer.py : 
        end_logits = accelerator.pad_across_processes(start_logits, dim=1, pad_index=-100)
which should be:
        end_logits = accelerator.pad_across_processes(end_logits, dim=1, pad_index=-100)

I'm not sure if it has been corrected in the latest version of transformers. I guess it's still there in https://github.com/huggingface/transformers/blob/main/examples/pytorch/question-answering/run_qa_no_trainer.py

Hi @JiaQiSJTU ,

Thanks for pointing out,

Let me check on it.

Hi @sgugger,

Shall I fix this typo?
https://github.com/huggingface/transformers/blob/ffd19ee1de36188c6208855160b5ff930caa00c0/examples/pytorch/question-answering/run_qa_no_trainer.py#L794

Yes please!