docstr: A tests that checks if the conversion raises an error if the model contains an activation function
  that is not supported by `BetterTransformer`. Here we need to loop over the config files
docstr_tok: ["A","tests","that","checks","if","the","conversion","raises","an","error","if","the","model","contains","an","activation","function","that","is","not","supported","by","`","BetterTransformer","`",".","Here","we","need","to","loop","over","the","config","files"]
code: def test_raise_activation_fun(self, model_type: str):
      r"""
      A tests that checks if the conversion raises an error if the model contains an activation function
      that is not supported by `BetterTransformer`. Here we need to loop over the config files
      """
      if (
          BetterTransformerManager.requires_strict_validation(
              model_type
          )
          is False
      ):
          self.skipTest(
              "The architecture does not require a specific activation function"
          )
  
      if model_type in ["wav2vec2", "hubert", "bark"]:
          self.skipTest(
              "These architectures do not support deepcopy (raise unrelated error)"
          )
  
      layer_classes = BetterTransformerManager.MODEL_MAPPING[
          model_type
      ].keys()
      for layer_class in layer_classes:
          if isinstance(layer_class, list):
              layer_class = layer_class[0]
  
          if layer_class == "EncoderLayer":
              # Hardcode it for FSMT - see https://github.com/huggingface/optimum/pull/494
              class_name = "FSMT"
          elif layer_class == "TransformerBlock":
              # Hardcode it for distilbert - see https://github.com/huggingface/transformers/pull/19966
              class_name = "DistilBert"
          elif "EncoderLayer" in layer_class:
              class_name = layer_class[:-12]
          elif "Attention" in layer_class:
              class_name = layer_class[:-9]
          else:
              class_name = layer_class[:-5]
  
          hf_random_config = getattr(
              transformers, class_name + "Config"
          )()  # random config class for the model to test
          hf_random_config.hidden_act = "silu"
  
          hf_random_model = AutoModel.from_config(
              hf_random_config
          ).eval()
          with self.assertRaises(ValueError) as cm:
              _ = BetterTransformer.transform(
                  hf_random_model, keep_original_model=True
              )
          self.assertTrue("Activation function" in str(cm.exception))
  
file_path: optimum/tests/bettertransformer/test_common.py
imports: import tempfile
  import unittest
  from unittest.mock import patch
  import transformers
  from parameterized import parameterized
  from testing_utils import MODELS_DICT
  from transformers import AutoModel
  from optimum.bettertransformer import BetterTransformer, BetterTransformerManager
  from optimum.pipelines import pipeline
  from optimum.utils.testing_utils import grid_parameters
label_desc: Use image node_id 6 for calling the BetterTransformerIntegrationTests obj's underlying member method code with example usage: obj.test_raise_activation_fun(model_type) without return types