Same capabilities for exporting using torchscript as with ONNX
Author: darwinharianto
Pull request: no

### Feature request

There are two supported ways to serialize the model which is to use ONNX or to use torchscript.  Looking at the documentation, in [ONNX](https://huggingface.co/docs/transformers/main/serialization), ONNX exporter seemed to save both processor and model to a file, while torchscript exporter just export the model itself.

How do I do the same for the torchscript exporter?

Using ONNX
```
from pathlib import Path
from transformers.onnx import export
from transformers import AutoProcessor, AutoModel
from transformers import AutoConfig
from transformers.models.owlvit.configuration_owlvit import OwlViTOnnxConfig


onnx_path = Path("model.onnx")

model_ckpt = "google/owlvit-base-patch32"
config = AutoConfig.from_pretrained(model_ckpt)
onnx_config = OwlViTOnnxConfig(config)

base_model = AutoModel.from_pretrained(model_ckpt)
processor = AutoProcessor.from_pretrained(model_ckpt)
onnx_inputs, onnx_outputs = export(processor, base_model, onnx_config, onnx_config.default_onnx_opset, onnx_path)

```


What is the equivalent thing in torchscript?
```
from pathlib import Path
from transformers import AutoProcessor, AutoModel

base_model = AutoModel.from_pretrained(model_ckpt, torchscript=True)
processor = AutoProcessor.from_pretrained(model_ckpt, torchscript=True)

# what is this two line should be?
traced_model = torch.jit.trace(base_model, ??) # 
torch.jit.save(traced_model, "traced_bert.pt")
```


### Motivation

Being able to use torchscript on processor

### Your contribution

Anything that I can do

Comments:
@darwinharianto There's a guide on exporting to torchscript in the docs: https://huggingface.co/docs/transformers/torchscript

Let us know if there's any information missing there. 

I can safely export the model to torchscript using this code, but I get this `TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect.`. I assume I can ignore this for now(?).

this is the code to export the model
```
import torch
import numpy as np
from transformers import AutoModel, AutoProcessor, OwlViTModel, OwlViTProcessor
from PIL import Image
import requests

class MyOpenDetector(torch.nn.Module):
    def __init__(self, model=None):
        super(MyOpenDetector, self).__init__()
        self.model = model
    
    def forward(self, input_ids, pixel_values, attention_mask):
        # inputs = {"input_ids":x[0], "attention_mask":x[1], "pixel_values":x[2]}
        outputs = self.model(input_ids=input_ids, pixel_values=pixel_values, attention_mask=attention_mask)
        # print(type(outputs))
        logits_per_image = outputs[0]  # this is the image-text similarity score
        probs = logits_per_image.softmax(dim=1)  # we can take the softmax to get the label probabilities

        return probs
def save_owlvitmodel(inputs, modelname):

    openModel = AutoModel.from_pretrained(modelname, torchscript=True).eval()

    x = tuple([inputs['input_ids'], inputs['pixel_values'], inputs['attention_mask']])
    model = MyOpenDetector(model=openModel)
    traced_model = torch.jit.trace(model, x)
    torch.jit.save(traced_model, 'traced_owlvit.pt')

    return

modelname = "google/owlvit-base-patch32"
processor = AutoProcessor.from_pretrained(modelname, torchscript=True)
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(text=[["a photo of a cat", "a photo of a dog"]], images=torch.Tensor(np.asarray(image)), return_tensors="pt")

save_owlvitmodel(inputs, modelname)

loaded_model = torch.jit.load("traced_owlvit.pt")
loaded_model.eval()

x = tuple([inputs['input_ids'], inputs['pixel_values'], inputs['attention_mask']])
probs = loaded_model(*x)
print(probs)
```


how can I do the same for processor?
```
import torch
import numpy as np
from transformers import AutoModel, AutoProcessor, OwlViTModel, OwlViTProcessor
from PIL import Image
import requests
class MyOpenProcessor(torch.nn.Module):

    def __init__(self, processor=None):
        super(MyOpenProcessor, self).__init__()
        self.processor = processor
    
    def forward(self, text, images):
        outputs = self.processor(text=text, images=images, return_tensors="pt")
        return outputs

modelname = "google/owlvit-base-patch32"
processor = AutoProcessor.from_pretrained(modelname, torchscript=True)
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(text=[["a photo of a cat", "a photo of a dog"]], images=torch.Tensor(np.asarray(image)), return_tensors="pt")
x = tuple([[["a photo of a cat", "a photo of a dog"]], torch.Tensor(np.asarray(image))])
newProcessor = MyOpenProcessor(processor=processor)
traced_processor = torch.jit.trace(newProcessor, x)
```

this throws an error because there is this tuple of list list str