Passing in custom BartForConditionalGeneration model as generator to RagSequenceForGeneration
Author: nitarakad
Pull request: no

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version: 4.2.1
- Platform: Linux-4.19.112+-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.6.9
- PyTorch version (GPU?): 1.7.0+cu101 (False)
- Tensorflow version (GPU?): 2.4.0 (False)
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help
@patrickvonplaten, @lhoestq
<!-- Your issue will be replied to more quickly if you can figure out the right person to tag with @
 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

 albert, bert, GPT2, XLM: @LysandreJik
 tokenizers: @mfuntowicz
 Trainer: @sgugger
 Speed and Memory Benchmarks: @patrickvonplaten
 Model Cards: @julien-c
 TextGeneration: @TevenLeScao
 examples/distillation: @VictorSanh
 nlp datasets: [different repo](https://github.com/huggingface/nlp)
 rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)
 Text Generation: @patrickvonplaten @TevenLeScao
 Blenderbot: @patrickvonplaten
 Bart: @patrickvonplaten
 Marian: @patrickvonplaten
 Pegasus: @patrickvonplaten
 mBART: @patrickvonplaten
 T5: @patrickvonplaten
 Longformer/Reformer: @patrickvonplaten
 TransfoXL/XLNet: @TevenLeScao
 RAG: @patrickvonplaten, @lhoestq
 FSMT: @stas00
 examples/seq2seq: @patil-suraj
 examples/bert-loses-patience: @JetRunner
 ray/raytune: @richardliaw @amogkam
 tensorflow: @jplu
 examples/token-classification: @stefan-it
 documentation: @sgugger
 -->
## Information

Model I am using:
`RagSequenceForGeneration` using pretrained  `facebook/rag-sequence-nq` with a custom generator initialized with `BartForConditionalGeneration`

The problem arises when using:
In the docs (https://huggingface.co/transformers/model_doc/rag.html) it is stated that a `generator` can be used when initializing `RagSequenceForGeneration`. When using a custom pretrained BART model as the `generator`, I get the error:

`ModuleAttributeError: 'BartForConditionalGeneration' object has no attribute 'to_dict'`

To troubleshoot, I initialized my generator using pretrained `facebook/bart-basee`  and RAG model the following way:
```
from transformers import RagTokenizer, RagRetriever, RagSequenceForGeneration, BartForConditionalGeneration
model_name = 'facebook/bart-base'
generator = BartForConditionalGeneration.from_pretrained(model_name)
tokenizer = RagTokenizer.from_pretrained("facebook/rag-sequence-nq") 
retriever = RagRetriever.from_pretrained("facebook/rag-sequence-nq", index_name="exact", use_dummy_dataset=True) 
model = RagSequenceForGeneration.from_pretrained("facebook/rag-sequence-nq", retriever=retriever, generator=generator) 
```

However, I get the same `ModuleAttributeError`.

The tasks I am working on is:
I want to initialize a `RagSequenceForGeneration` with a custom generator.

## To reproduce

Steps to reproduce the behavior:

1. Run the code block above and the error is outputted: `ModuleAttributeError: 'BartForConditionalGeneration' object has no attribute 'to_dict'`

<!-- If you have code snippets, error messages, stack traces please provide them here as well.
     Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
     Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.-->

## Expected behavior

<!-- A clear and concise description of what you would expect to happen. -->

Expected model to initialize with a custom generator, as described in the docs (https://huggingface.co/transformers/model_doc/rag.html).



Comments:
Solved by using `RagConfig` and initializing it with a `DPRQuestionEncoder` and the custom `BartForConditionalGeneration` generator configs. Passed the `RagConfig`, question encoder, generator, and retriever, to `RagModel` to initialize the model.

Could you provide a complete sample code about how to do it? I'm stuck at how to do the config initialization for a DPR + customized BartForCondGen. Thanks!