`FlaxBartForConditionalGeneration` has a `.encode` method but `BartForConditionalGeneration` does not
## Environment info

- `transformers` version: 4.18.0
- Platform: Linux-5.11.0-1018-gcp-x86_64-with-glibc2.31
- Python version: 3.10.4
- Huggingface_hub version: 0.5.1
- PyTorch version (GPU?): 1.11.0+cu102 (False)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): 0.4.1 (tpu)
- Jax version: 0.3.5
- JaxLib version: 0.3.5
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help

@patil-suraj

## Information

Model I am using: BART

## To reproduce

Flax version (working):

```python
from transformers import BartTokenizer, FlaxBartForConditionalGeneration

tokenizer = BartTokenizer.from_pretrained('facebook/bart-base')
model = FlaxBartForConditionalGeneration.from_pretrained('facebook/bart-base')
inputs = tokenizer('Travelers wait about an hour and a half to cross the Tower.', return_tensors='jax')
outputs = model.encode(**inputs)
print(outputs)  # OK
```

PyTorch version (not working):

```python
from transformers import BartTokenizer, BartForConditionalGeneration

tokenizer = BartTokenizer.from_pretrained('facebook/bart-base')
model = BartForConditionalGeneration.from_pretrained('facebook/bart-base')
inputs = tokenizer('Travelers wait about an hour and a half to cross the Tower.', return_tensors='pt')
outputs = model.encode(**inputs)  # AttributeError: 'BartForConditionalGeneration' object has no attribute 'encode'
```

## Expected behavior

The PyTorch version should also have a `.encode` method to generate the encoder output, as the Flax version does.

## Actual behavior

The PyTorch version does not a `.encode` method.
Hi! The `encode` method does not exist in PT model because it's possible to access the encoder using `model.get_encoder` and then call it to run the encoder. Flax does not allow accessing modules like this so we need to expose explicit methods like `encode`. This is not required for PT.<|||||>Thanks for the explanation!