Trouble exporting resolve_conj operation to ONNX
## 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.16.2
- Platform: Linux-5.13.0-39-generic-x86_64-with-glibc2.34
- Python version: 3.9.7
- PyTorch version (GPU?): 1.10.2+cu113 (True)
- Tensorflow version (GPU?): 2.8.0 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No


### Who can help
<!-- 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.

Models:

- ALBERT, BERT, XLM, DeBERTa, DeBERTa-v2, ELECTRA, MobileBert, SqueezeBert: @LysandreJik
- T5, Pegasus, EncoderDecoder: @patrickvonplaten
- Blenderbot, MBART, BART, Marian, Pegasus: @patil-suraj
- Reformer, TransfoXL, XLNet, FNet: @patrickvonplaten
- Longformer, BigBird: @ydshieh
- FSMT: @stas00
- Funnel: @sgugger
- GPT-2, GPT: @patil-suraj, @patrickvonplaten, @LysandreJik
- RAG, DPR: @patrickvonplaten, @lhoestq
- TensorFlow: @Rocketknight1
- JAX/Flax: @patil-suraj
- TAPAS, LayoutLM, LayoutLMv2, LUKE, ViT, BEiT, DEiT, DETR, CANINE: @NielsRogge
- GPT-Neo, GPT-J, CLIP: @patil-suraj
- Wav2Vec2, HuBERT, SpeechEncoderDecoder, UniSpeech, UniSpeechSAT, SEW, SEW-D, Speech2Text: @patrickvonplaten, @anton-l

If the model isn't in the list, ping @LysandreJik who will redirect you to the correct contributor.

Library:

- Benchmarks: @patrickvonplaten
- Deepspeed: @stas00
- Ray/raytune: @richardliaw, @amogkam
- Text generation: @patrickvonplaten @narsil
- Tokenizers: @SaulLu
- Trainer: @sgugger
- Pipelines: @Narsil
- Speech: @patrickvonplaten, @anton-l
- Vision: @NielsRogge, @sgugger

Documentation: @sgugger

Model hub:

- for issues with a model, report at https://discuss.huggingface.co/ and tag the model's creator.

HF projects:

- datasets: [different repo](https://github.com/huggingface/datasets)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj

For research projetcs, please ping the contributor directly. For example, on the following projects:

- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->

## Information

Model I am using (Bert, XLNet ...): Helsinki-NLP/opus-mt-xx-xx

The problem arises when using:
* [ ] the official example scripts: (give details below)
* [X] my own modified scripts: (give details below)

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [x] my own task or dataset: (give details below)

## To reproduce

Steps to reproduce the behavior:

1. Run below script

```
import torch.nn as nn
from transformers import MarianMTModel
from transformers import AutoTokenizer
import torch


class HelsinkiModel(nn.Module):

    def __init__(self, model_id, device):
        super(HelsinkiModel, self).__init__()
        self.mt_model = MarianMTModel.from_pretrained(model_id).to(device)
        self.mt_model.eval()
        self.device = device

    def forward(self, input_ids, attention_mask):
        return self.mt_model.generate(input_ids=input_ids, attention_mask=attention_mask, repetition_penalty=0.7)

model = HelsinkiModel('Helsinki-NLP/opus-mt-fr-en', 'cpu')
tokenizer = AutoTokenizer.from_pretrained('Helsinki-NLP/opus-mt-fr-en')
inputs = tokenizer("Une phrase d'exemple", padding='max_length', max_length=512, truncation=True, return_tensors="pt")
inputs = (inputs["input_ids"].to(device), inputs["attention_mask"].to(device))
torch.onnx.export(model, inputs, path, export_params=True, opset_version=14, do_constant_folding=False,
                  input_names=["input_ids", "attention_mask"], output_names=["outputs"], 
                  dynamic_axes={'input_ids': {0: 'batch_size'}, 'attention_mask': {0: 'batch_size'}, 'outputs': {0: 'batch_size'}})
```

<!-- 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.-->

## Error trace
```
/home/.local/lib/python3.9/site-packages/transformers/models/marian/modeling_marian.py:234: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if attn_weights.size() != (bsz * self.num_heads, tgt_len, src_len):
/home/.local/lib/python3.9/site-packages/transformers/models/marian/modeling_marian.py:240: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if attention_mask.size() != (bsz, 1, tgt_len, src_len):
/home/.local/lib/python3.9/site-packages/transformers/models/marian/modeling_marian.py:271: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if attn_output.size() != (bsz * self.num_heads, tgt_len, self.head_dim):
/home/.local/lib/python3.9/site-packages/transformers/generation_utils.py:1119: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if input_ids.shape[-1] >= max_length:
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:180: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  self._done = torch.tensor([False for _ in range(batch_size)], dtype=torch.bool, device=self.device)
/home/.local/lib/python3.9/site-packages/transformers/generation_utils.py:1934: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if num_beams * batch_size != batch_beam_size:
/home/.local/lib/python3.9/site-packages/transformers/models/marian/modeling_marian.py:850: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if input_shape[-1] > 1:
/home/.local/lib/python3.9/site-packages/transformers/generation_logits_process.py:389: TracerWarning: Converting a tensor to a Python list might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  dynamic_banned_tokens = self._calc_banned_bad_words_ids(input_ids.tolist())
/home/.local/lib/python3.9/site-packages/transformers/generation_logits_process.py:120: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if cur_len < self.min_length:
/home/.local/lib/python3.9/site-packages/transformers/generation_logits_process.py:595: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if cur_len == self.max_length - 1:
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:215: UserWarning: __floordiv__ is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor').
  if not (batch_size == (input_ids.shape[0] // self.group_size)):
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:215: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if not (batch_size == (input_ids.shape[0] // self.group_size)):
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:233: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if self._done[batch_idx]:
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:247: TracerWarning: Iterating over a tensor might cause the trace to be incorrect. Passing a tensor of different shape won't change the number of iterations executed (and might lead to errors or silently give incorrect results).
  zip(next_tokens[batch_idx], next_scores[batch_idx], next_indices[batch_idx])
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:251: TracerWarning: Converting a tensor to a Python number might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if (eos_token_id is not None) and (next_token.item() == eos_token_id):
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:277: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  self._done[batch_idx] = self._done[batch_idx] or beam_hyp.is_done(
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:278: TracerWarning: Converting a tensor to a Python number might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  next_scores[batch_idx].max().item(), cur_len
/home/.local/lib/python3.9/site-packages/transformers/generation_utils.py:2053: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if beam_scorer.is_done or stopping_criteria(input_ids, scores):
/home/.local/lib/python3.9/site-packages/transformers/generation_stopping_criteria.py:113: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  return any(criteria(input_ids, scores) for criteria in self)
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:258: TracerWarning: Converting a tensor to a Python number might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  next_score.item(),
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:382: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  self.worst_score = min(score, self.worst_score)
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:375: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if len(self) < self.num_beams or score > self.worst_score:
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:378: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  sorted_next_scores = sorted([(s, idx) for idx, (s, _) in enumerate(self.beams)])
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:303: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if self._done[batch_idx]:
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:321: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  sorted_hyps = sorted(beam_hyp.beams, key=lambda x: x[0])
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:326: TracerWarning: Using len to get tensor shape might cause the trace to be incorrect. Recommended usage would be tensor.shape[0]. Passing a tensor of different shape might lead to errors or silently give incorrect results.
  sent_lengths[self.num_beam_hyps_to_keep * i + j] = len(best_hyp)
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:333: TracerWarning: Converting a tensor to a Python number might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  sent_max_len = min(sent_lengths.max().item() + 1, max_length)
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:336: TracerWarning: Converting a tensor to a Python number might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if sent_lengths.min().item() != sent_lengths.max().item():
/home/.local/lib/python3.9/site-packages/transformers/generation_beam_search.py:343: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if sent_lengths[i] < max_length:
/home/.local/lib/python3.9/site-packages/torch/onnx/symbolic_helper.py:716: UserWarning: allowzero=0 by default. In order to honor zero value in shape use allowzero=1
  warnings.warn("allowzero=0 by default. In order to honor zero value in shape use allowzero=1")
Traceback (most recent call last):
  File "/home/repos/translation-service/scripts/onnx_main.py", line 24, in <module>
    export_to_onnx(model, 'example.onnx', inputs, device)
  File "/home/repos/translation-service/models/model_helper.py", line 14, in export_to_onnx
    torch.onnx.export(model, inputs, path, export_params=True, opset_version=14, do_constant_folding=False,
  File "/home/.local/lib/python3.9/site-packages/torch/onnx/__init__.py", line 316, in export
    return utils.export(model, args, f, export_params, verbose, training,
  File "/home/.local/lib/python3.9/site-packages/torch/onnx/utils.py", line 107, in export
    _export(model, args, f, export_params, verbose, training, input_names, output_names,
  File "/home/.local/lib/python3.9/site-packages/torch/onnx/utils.py", line 724, in _export
    _model_to_graph(model, args, verbose, input_names,
  File "/home/.local/lib/python3.9/site-packages/torch/onnx/utils.py", line 497, in _model_to_graph
    graph = _optimize_graph(graph, operator_export_type,
  File "/home/.local/lib/python3.9/site-packages/torch/onnx/utils.py", line 216, in _optimize_graph
    graph = torch._C._jit_pass_onnx(graph, operator_export_type)
  File "/home/.local/lib/python3.9/site-packages/torch/onnx/__init__.py", line 373, in _run_symbolic_function
    return utils._run_symbolic_function(*args, **kwargs)
  File "/home/.local/lib/python3.9/site-packages/torch/onnx/utils.py", line 1028, in _run_symbolic_function
    symbolic_fn = _find_symbolic_in_registry(domain, op_name, opset_version, operator_export_type)
  File "/home/.local/lib/python3.9/site-packages/torch/onnx/utils.py", line 982, in _find_symbolic_in_registry
    return sym_registry.get_registered_op(op_name, domain, opset_version)
  File "/home/.local/lib/python3.9/site-packages/torch/onnx/symbolic_registry.py", line 125, in get_registered_op
    raise RuntimeError(msg)
RuntimeError: Exporting the operator resolve_conj to ONNX opset version 14 is not supported. Please feel free to request support or submit a pull request on PyTorch GitHub.

```

## Expected behavior

A succesfull ONNX export.

There are numerous warnings. I cannot test if these are problematic, because the model as a whole does not export. I want to resolve the final RuntimeError, which refers to the resolve_conj pytorch operation. I've no idea where in the model this operation is used.

If anyone has a clear cut solution to exporting these models, I'd be happy to hear it. But for starters, I would very much like to see where in the source code of these models this function is, since I don't seem to be able to find it.

Why are you using `opset=14` ?
I think that 12 or 13 would be enough and would work.<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.