We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
BetterTransformer support for Marian
`The model type marian is not yet supported supported to be used with BetterTransformer.`

Wondering if there is a way to get this working with BetterTransformer. I am trying to get this model translating faster. https://huggingface.co/Helsinki-NLP/opus-mt-zh-en?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `optimum/bettertransformer/models/__init__.py`
Content:
```
1 # Copyright 2022 The HuggingFace Team. All rights reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 import warnings
15 
16 from .encoder_models import (
17     AlbertLayerBetterTransformer,
18     BartEncoderLayerBetterTransformer,
19     BertLayerBetterTransformer,
20     CLIPLayerBetterTransformer,
21     DistilBertLayerBetterTransformer,
22     FSMTEncoderLayerBetterTransformer,
23     MBartEncoderLayerBetterTransformer,
24     ViltLayerBetterTransformer,
25     ViTLayerBetterTransformer,
26     Wav2Vec2EncoderLayerBetterTransformer,
27     WhisperEncoderLayerBetterTransformer,
28 )
29 
30 
31 class BetterTransformerManager:
32     MODEL_MAPPING = {
33         "albert": ("AlbertLayer", AlbertLayerBetterTransformer),
34         "bart": ("BartEncoderLayer", BartEncoderLayerBetterTransformer),
35         "bert": ("BertLayer", BertLayerBetterTransformer),
36         "bert-generation": ("BertGenerationLayer", BertLayerBetterTransformer),
37         "camembert": ("CamembertLayer", BertLayerBetterTransformer),
38         "clip": ("CLIPEncoderLayer", CLIPLayerBetterTransformer),
39         "data2vec-text": ("Data2VecTextLayer", BertLayerBetterTransformer),
40         "deit": ("DeiTLayer", ViTLayerBetterTransformer),
41         "distilbert": ("TransformerBlock", DistilBertLayerBetterTransformer),
42         "electra": ("ElectraLayer", BertLayerBetterTransformer),
43         "ernie": ("ErnieLayer", BertLayerBetterTransformer),
44         "fsmt": ("EncoderLayer", FSMTEncoderLayerBetterTransformer),
45         "hubert": ("HubertEncoderLayer", Wav2Vec2EncoderLayerBetterTransformer),
46         "layoutlm": ("LayoutLMLayer", BertLayerBetterTransformer),
47         "m2m_100": ("M2M100EncoderLayer", MBartEncoderLayerBetterTransformer),
48         "markuplm": ("MarkupLMLayer", BertLayerBetterTransformer),
49         "mbart": ("MBartEncoderLayer", MBartEncoderLayerBetterTransformer),
50         "rembert": ("RemBertLayer", BertLayerBetterTransformer),
51         "roberta": ("RobertaLayer", BertLayerBetterTransformer),
52         "roc_bert": ("RoCBertLayer", BertLayerBetterTransformer),
53         "roformer": ("RoFormerLayer", BertLayerBetterTransformer),
54         "splinter": ("SplinterLayer", BertLayerBetterTransformer),
55         "tapas": ("TapasLayer", BertLayerBetterTransformer),
56         "vilt": ("ViltLayer", ViltLayerBetterTransformer),
57         "vit": ("ViTLayer", ViTLayerBetterTransformer),
58         "vit_mae": ("ViTMAELayer", ViTLayerBetterTransformer),
59         "vit_msn": ("ViTMSNLayer", ViTLayerBetterTransformer),
60         "wav2vec2": (
61             ["Wav2Vec2EncoderLayer", "Wav2Vec2EncoderLayerStableLayerNorm"],
62             Wav2Vec2EncoderLayerBetterTransformer,
63         ),
64         "whisper": ("WhisperEncoderLayer", WhisperEncoderLayerBetterTransformer),
65         "xlm-roberta": ("XLMRobertaLayer", BertLayerBetterTransformer),
66         "yolos": ("YolosLayer", ViTLayerBetterTransformer),
67     }
68 
69     EXCLUDE_FROM_TRANSFORM = {
70         # clip's text model uses causal attention, that is most likely not supported in BetterTransformer
71         "clip": ["text_model"],
72     }
73 
74     CAN_NOT_BE_SUPPORTED = {
75         "deberta-v2": "DeBERTa v2 does not use a regular attention mechanism, which is not suppored in PyTorch's BetterTransformer.",
76         "glpn": "GLPN has a convolutional layer present in the FFN network, which is not suppored in PyTorch's BetterTransformer.",
77         "t5": "T5 uses attention bias, which is not suppored in PyTorch's BetterTransformer.",
78     }
79 
80     @staticmethod
81     def cannot_support(model_type: str) -> bool:
82         """
83         Returns True if a given model type can not be supported by PyTorch's Better Transformer.
84 
85         Args:
86             model_type (`str`):
87                 The model type to check.
88         """
89         return model_type in BetterTransformerManager.CAN_NOT_BE_SUPPORTED
90 
91     @staticmethod
92     def supports(model_type: str) -> bool:
93         """
94         Returns True if a given model type is supported by PyTorch's Better Transformer, and integrated in Optimum.
95 
96         Args:
97             model_type (`str`):
98                 The model type to check.
99         """
100         return model_type in BetterTransformerManager.MODEL_MAPPING
101 
102 
103 class warn_uncompatible_save(object):
104     def __init__(self, callback):
105         self.callback = callback
106 
107     def __enter__(self):
108         return self
109 
110     def __exit__(self, ex_typ, ex_val, traceback):
111         return True
112 
113     def __call__(self, *args, **kwargs):
114         warnings.warn(
115             "You are calling `save_pretrained` to a `BetterTransformer` converted model you may likely encounter unexepected behaviors. ",
116             UserWarning,
117         )
118         return self.callback(*args, **kwargs)
119
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/optimum/bettertransformer/models/__init__.py b/optimum/bettertransformer/models/__init__.py
--- a/optimum/bettertransformer/models/__init__.py
+++ b/optimum/bettertransformer/models/__init__.py
@@ -45,6 +45,7 @@
         "hubert": ("HubertEncoderLayer", Wav2Vec2EncoderLayerBetterTransformer),
         "layoutlm": ("LayoutLMLayer", BertLayerBetterTransformer),
         "m2m_100": ("M2M100EncoderLayer", MBartEncoderLayerBetterTransformer),
+        "marian": ("MarianEncoderLayer", BartEncoderLayerBetterTransformer),
         "markuplm": ("MarkupLMLayer", BertLayerBetterTransformer),
         "mbart": ("MBartEncoderLayer", MBartEncoderLayerBetterTransformer),
         "rembert": ("RemBertLayer", BertLayerBetterTransformer),

{"golden_diff": "diff --git a/optimum/bettertransformer/models/__init__.py b/optimum/bettertransformer/models/__init__.py\n--- a/optimum/bettertransformer/models/__init__.py\n+++ b/optimum/bettertransformer/models/__init__.py\n@@ -45,6 +45,7 @@\n         \"hubert\": (\"HubertEncoderLayer\", Wav2Vec2EncoderLayerBetterTransformer),\n         \"layoutlm\": (\"LayoutLMLayer\", BertLayerBetterTransformer),\n         \"m2m_100\": (\"M2M100EncoderLayer\", MBartEncoderLayerBetterTransformer),\n+        \"marian\": (\"MarianEncoderLayer\", BartEncoderLayerBetterTransformer),\n         \"markuplm\": (\"MarkupLMLayer\", BertLayerBetterTransformer),\n         \"mbart\": (\"MBartEncoderLayer\", MBartEncoderLayerBetterTransformer),\n         \"rembert\": (\"RemBertLayer\", BertLayerBetterTransformer),\n", "issue": "BetterTransformer support for Marian\n`The model type marian is not yet supported supported to be used with BetterTransformer.`\r\n\r\nWondering if there is a way to get this working with BetterTransformer. I am trying to get this model translating faster. https://huggingface.co/Helsinki-NLP/opus-mt-zh-en?\n", "before_files": [{"content": "# Copyright 2022 The HuggingFace Team. All rights reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport warnings\n\nfrom .encoder_models import (\n    AlbertLayerBetterTransformer,\n    BartEncoderLayerBetterTransformer,\n    BertLayerBetterTransformer,\n    CLIPLayerBetterTransformer,\n    DistilBertLayerBetterTransformer,\n    FSMTEncoderLayerBetterTransformer,\n    MBartEncoderLayerBetterTransformer,\n    ViltLayerBetterTransformer,\n    ViTLayerBetterTransformer,\n    Wav2Vec2EncoderLayerBetterTransformer,\n    WhisperEncoderLayerBetterTransformer,\n)\n\n\nclass BetterTransformerManager:\n    MODEL_MAPPING = {\n        \"albert\": (\"AlbertLayer\", AlbertLayerBetterTransformer),\n        \"bart\": (\"BartEncoderLayer\", BartEncoderLayerBetterTransformer),\n        \"bert\": (\"BertLayer\", BertLayerBetterTransformer),\n        \"bert-generation\": (\"BertGenerationLayer\", BertLayerBetterTransformer),\n        \"camembert\": (\"CamembertLayer\", BertLayerBetterTransformer),\n        \"clip\": (\"CLIPEncoderLayer\", CLIPLayerBetterTransformer),\n        \"data2vec-text\": (\"Data2VecTextLayer\", BertLayerBetterTransformer),\n        \"deit\": (\"DeiTLayer\", ViTLayerBetterTransformer),\n        \"distilbert\": (\"TransformerBlock\", DistilBertLayerBetterTransformer),\n        \"electra\": (\"ElectraLayer\", BertLayerBetterTransformer),\n        \"ernie\": (\"ErnieLayer\", BertLayerBetterTransformer),\n        \"fsmt\": (\"EncoderLayer\", FSMTEncoderLayerBetterTransformer),\n        \"hubert\": (\"HubertEncoderLayer\", Wav2Vec2EncoderLayerBetterTransformer),\n        \"layoutlm\": (\"LayoutLMLayer\", BertLayerBetterTransformer),\n        \"m2m_100\": (\"M2M100EncoderLayer\", MBartEncoderLayerBetterTransformer),\n        \"markuplm\": (\"MarkupLMLayer\", BertLayerBetterTransformer),\n        \"mbart\": (\"MBartEncoderLayer\", MBartEncoderLayerBetterTransformer),\n        \"rembert\": (\"RemBertLayer\", BertLayerBetterTransformer),\n        \"roberta\": (\"RobertaLayer\", BertLayerBetterTransformer),\n        \"roc_bert\": (\"RoCBertLayer\", BertLayerBetterTransformer),\n        \"roformer\": (\"RoFormerLayer\", BertLayerBetterTransformer),\n        \"splinter\": (\"SplinterLayer\", BertLayerBetterTransformer),\n        \"tapas\": (\"TapasLayer\", BertLayerBetterTransformer),\n        \"vilt\": (\"ViltLayer\", ViltLayerBetterTransformer),\n        \"vit\": (\"ViTLayer\", ViTLayerBetterTransformer),\n        \"vit_mae\": (\"ViTMAELayer\", ViTLayerBetterTransformer),\n        \"vit_msn\": (\"ViTMSNLayer\", ViTLayerBetterTransformer),\n        \"wav2vec2\": (\n            [\"Wav2Vec2EncoderLayer\", \"Wav2Vec2EncoderLayerStableLayerNorm\"],\n            Wav2Vec2EncoderLayerBetterTransformer,\n        ),\n        \"whisper\": (\"WhisperEncoderLayer\", WhisperEncoderLayerBetterTransformer),\n        \"xlm-roberta\": (\"XLMRobertaLayer\", BertLayerBetterTransformer),\n        \"yolos\": (\"YolosLayer\", ViTLayerBetterTransformer),\n    }\n\n    EXCLUDE_FROM_TRANSFORM = {\n        # clip's text model uses causal attention, that is most likely not supported in BetterTransformer\n        \"clip\": [\"text_model\"],\n    }\n\n    CAN_NOT_BE_SUPPORTED = {\n        \"deberta-v2\": \"DeBERTa v2 does not use a regular attention mechanism, which is not suppored in PyTorch's BetterTransformer.\",\n        \"glpn\": \"GLPN has a convolutional layer present in the FFN network, which is not suppored in PyTorch's BetterTransformer.\",\n        \"t5\": \"T5 uses attention bias, which is not suppored in PyTorch's BetterTransformer.\",\n    }\n\n    @staticmethod\n    def cannot_support(model_type: str) -> bool:\n        \"\"\"\n        Returns True if a given model type can not be supported by PyTorch's Better Transformer.\n\n        Args:\n            model_type (`str`):\n                The model type to check.\n        \"\"\"\n        return model_type in BetterTransformerManager.CAN_NOT_BE_SUPPORTED\n\n    @staticmethod\n    def supports(model_type: str) -> bool:\n        \"\"\"\n        Returns True if a given model type is supported by PyTorch's Better Transformer, and integrated in Optimum.\n\n        Args:\n            model_type (`str`):\n                The model type to check.\n        \"\"\"\n        return model_type in BetterTransformerManager.MODEL_MAPPING\n\n\nclass warn_uncompatible_save(object):\n    def __init__(self, callback):\n        self.callback = callback\n\n    def __enter__(self):\n        return self\n\n    def __exit__(self, ex_typ, ex_val, traceback):\n        return True\n\n    def __call__(self, *args, **kwargs):\n        warnings.warn(\n            \"You are calling `save_pretrained` to a `BetterTransformer` converted model you may likely encounter unexepected behaviors. \",\n            UserWarning,\n        )\n        return self.callback(*args, **kwargs)\n", "path": "optimum/bettertransformer/models/__init__.py"}], "after_files": [{"content": "# Copyright 2022 The HuggingFace Team. All rights reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport warnings\n\nfrom .encoder_models import (\n    AlbertLayerBetterTransformer,\n    BartEncoderLayerBetterTransformer,\n    BertLayerBetterTransformer,\n    CLIPLayerBetterTransformer,\n    DistilBertLayerBetterTransformer,\n    FSMTEncoderLayerBetterTransformer,\n    MBartEncoderLayerBetterTransformer,\n    ViltLayerBetterTransformer,\n    ViTLayerBetterTransformer,\n    Wav2Vec2EncoderLayerBetterTransformer,\n    WhisperEncoderLayerBetterTransformer,\n)\n\n\nclass BetterTransformerManager:\n    MODEL_MAPPING = {\n        \"albert\": (\"AlbertLayer\", AlbertLayerBetterTransformer),\n        \"bart\": (\"BartEncoderLayer\", BartEncoderLayerBetterTransformer),\n        \"bert\": (\"BertLayer\", BertLayerBetterTransformer),\n        \"bert-generation\": (\"BertGenerationLayer\", BertLayerBetterTransformer),\n        \"camembert\": (\"CamembertLayer\", BertLayerBetterTransformer),\n        \"clip\": (\"CLIPEncoderLayer\", CLIPLayerBetterTransformer),\n        \"data2vec-text\": (\"Data2VecTextLayer\", BertLayerBetterTransformer),\n        \"deit\": (\"DeiTLayer\", ViTLayerBetterTransformer),\n        \"distilbert\": (\"TransformerBlock\", DistilBertLayerBetterTransformer),\n        \"electra\": (\"ElectraLayer\", BertLayerBetterTransformer),\n        \"ernie\": (\"ErnieLayer\", BertLayerBetterTransformer),\n        \"fsmt\": (\"EncoderLayer\", FSMTEncoderLayerBetterTransformer),\n        \"hubert\": (\"HubertEncoderLayer\", Wav2Vec2EncoderLayerBetterTransformer),\n        \"layoutlm\": (\"LayoutLMLayer\", BertLayerBetterTransformer),\n        \"m2m_100\": (\"M2M100EncoderLayer\", MBartEncoderLayerBetterTransformer),\n        \"marian\": (\"MarianEncoderLayer\", BartEncoderLayerBetterTransformer),\n        \"markuplm\": (\"MarkupLMLayer\", BertLayerBetterTransformer),\n        \"mbart\": (\"MBartEncoderLayer\", MBartEncoderLayerBetterTransformer),\n        \"rembert\": (\"RemBertLayer\", BertLayerBetterTransformer),\n        \"roberta\": (\"RobertaLayer\", BertLayerBetterTransformer),\n        \"roc_bert\": (\"RoCBertLayer\", BertLayerBetterTransformer),\n        \"roformer\": (\"RoFormerLayer\", BertLayerBetterTransformer),\n        \"splinter\": (\"SplinterLayer\", BertLayerBetterTransformer),\n        \"tapas\": (\"TapasLayer\", BertLayerBetterTransformer),\n        \"vilt\": (\"ViltLayer\", ViltLayerBetterTransformer),\n        \"vit\": (\"ViTLayer\", ViTLayerBetterTransformer),\n        \"vit_mae\": (\"ViTMAELayer\", ViTLayerBetterTransformer),\n        \"vit_msn\": (\"ViTMSNLayer\", ViTLayerBetterTransformer),\n        \"wav2vec2\": (\"Wav2Vec2EncoderLayer\", Wav2Vec2EncoderLayerBetterTransformer),\n        \"whisper\": (\"WhisperEncoderLayer\", WhisperEncoderLayerBetterTransformer),\n        \"xlm-roberta\": (\"XLMRobertaLayer\", BertLayerBetterTransformer),\n        \"yolos\": (\"YolosLayer\", ViTLayerBetterTransformer),\n    }\n\n    EXCLUDE_FROM_TRANSFORM = {\n        # clip's text model uses causal attention, that is most likely not supported in BetterTransformer\n        \"clip\": [\"text_model\"],\n    }\n\n    CAN_NOT_BE_SUPPORTED = {\n        \"deberta-v2\": \"DeBERTa v2 does not use a regular attention mechanism, which is not suppored in PyTorch's BetterTransformer.\",\n        \"glpn\": \"GLPN has a convolutional layer present in the FFN network, which is not suppored in PyTorch's BetterTransformer.\",\n        \"t5\": \"T5 uses attention bias, which is not suppored in PyTorch's BetterTransformer.\",\n    }\n\n    @staticmethod\n    def cannot_support(model_type: str) -> bool:\n        \"\"\"\n        Returns True if a given model type can not be supported by PyTorch's Better Transformer.\n\n        Args:\n            model_type (`str`):\n                The model type to check.\n        \"\"\"\n        return model_type in BetterTransformerManager.CAN_NOT_BE_SUPPORTED\n\n    @staticmethod\n    def supports(model_type: str) -> bool:\n        \"\"\"\n        Returns True if a given model type is supported by PyTorch's Better Transformer, and integrated in Optimum.\n\n        Args:\n            model_type (`str`):\n                The model type to check.\n        \"\"\"\n        return model_type in BetterTransformerManager.MODEL_MAPPING\n\n\nclass warn_uncompatible_save(object):\n    def __init__(self, callback):\n        self.callback = callback\n\n    def __enter__(self):\n        return self\n\n    def __exit__(self, ex_typ, ex_val, traceback):\n        return True\n\n    def __call__(self, *args, **kwargs):\n        warnings.warn(\n            \"You are calling `save_pretrained` to a `BetterTransformer` converted model you may likely encounter unexepected behaviors. \",\n            UserWarning,\n        )\n        return self.callback(*args, **kwargs)\n", "path": "optimum/bettertransformer/models/__init__.py"}]}