Owlvit memory leak fix
Author: alaradirik
Pull request: yes

# What does this PR do?
- Fixes memory leak in calls to `OwlViTForObjectDetection` model. The memory leak was due to making calls to `OwlViTModel`'s `get_image_features` and `get_text_features` methods. Replacing the calls to these methods with a single call to the` forward` method fixed the issue.
- Fixes typos regarding expected input shapes, this is discussed in another [PR](https://github.com/huggingface/transformers/pull/18450).
- Eliminates calling `self.owlvit()` within `OwlViTForObjectDetection.forward()` twice when `output_hidden_states` is set to True.

Memory usage profile after the fix:
```
import requests
from PIL import Image
from tqdm import trange
import torch

from transformers import OwlViTModel, OwlViTForObjectDetection, OwlViTProcessor

model = OwlViTForObjectDetection.from_pretrained("google/owlvit-base-patch32")
processor = OwlViTProcessor.from_pretrained("google/owlvit-base-patch32")

text_prompts = ["a photo of a cat", "a photo of a dog"]
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(text=[text_prompts], images=image, return_tensors="pt")

for i in range(50):
    with torch.no_grad():
        _ = model(**inputs)
```

![Figure_1](https://user-images.githubusercontent.com/8944735/186164960-439fa1fa-93b5-45b9-a2e1-045d4a07b554.png)

Fixes # 18629

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ X] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? 
   This was discussed in this [issue](https://github.com/huggingface/transformers/issues/18629).
- [ X] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [X ] Did you write any new necessary tests?


 -->


Comments:
_The documentation is not available anymore as the PR was closed or merged._

> I don't have any problem with the PR but I'd like the review of @amyeroberts, @NielsRogge and/or @sgugger as well if possible.
> 
> Do you have insights on why using `get_text_features` and `get_image_features` resulted in memory leaks? It seems to me like the previous usage wasn't wrong, so I wonder if these methods shouldn't be fixed as well to prevent the leakage.

Thank you @LysandreJik! `OwlViTModel.forward()` already includes the code of `OwlViTModel.get_text_features `and `OwlViTModel.get_image_features`. I was able to replicate the issue with a toy example with two PyTorch models, where one model object is set as the other one's attribute. Calling a non-forward function of the attribute model causes memory leaks. 

> Could you post a profile before the change for comparison?

Thank you @amyeroberts! I changed the last hidden state variable names. I'm also including a snapshot of memory usage (without using `torch.no_grad()`) before the fix:
![before](https://user-images.githubusercontent.com/8944735/187627988-968133c6-d5c7-4b40-abf5-c3fa7d8be811.png)