docstr: Base layer for `BetterTransformer` integration. This class is used to wrap all the necessary
  components for the `BetterTransformer` integration.
  
  Args:
      config (`transformers.PretrainedConfig`):
          The config of the model.
docstr_tok: ["Base","layer","for","`","BetterTransformer","`","integration",".","This","class","is","used","to","wrap","all","the","necessary","components","for","the","`","BetterTransformer","`","integration",".","Args",":","config","(","`","transformers.PretrainedConfig","`",")",":","The","config","of","the","model","."]
code: def __init__(
      self,
      config: "PretrainedConfig",
  ):
      r"""
      Base layer for `BetterTransformer` integration. This class is used to wrap all the necessary
      components for the `BetterTransformer` integration.
  
      Args:
          config (`transformers.PretrainedConfig`):
              The config of the model.
      """
      self.norm_first = False
      self.use_gelu = False
      self.act_fn = None
      self.pos_emb_type = None
      self.num_heads = None
      self.embed_dim = None
      self.num_layers = None
      self.original_layers_mapping = {}
      self.module_mapping = None
      # Some models does not have some attributes thus needs to be ignored
      # e.g. whisper does not have self_attn.k_proj.bias but has self_attn.v_proj.bias & self_attn.q_proj.bias
      self.keys_to_ignore = []
  
      # Get activation function
      for attr in KNOWN_ACTIVATION_ATTRIBUTES:
          if hasattr(config, attr):
              self.act_fn = getattr(config, attr)
              break
  
      # if act_fn not found in the config, fall back to the private `_get_activation_function` if available
      if self.act_fn is None and hasattr(
          self, "_get_activation_function"
      ):
          self.act_fn = self._get_activation_function(config)
  
      # Get pos emb type
      for attr in KNOWN_POS_EMB_ATTRIBUTES:
          if hasattr(config, attr):
              self.pos_emb_type = getattr(config, attr)
              break
  
      # Get num_layers
      for attr in KNOWN_NUM_LAYERS:
          if hasattr(config, attr):
              self.num_layers = getattr(config, attr)
              break
  
imports: from typing import TYPE_CHECKING
  import torch
  from ...utils import logging, recurse_getattr, recurse_setattr
label_desc: Use image node_id 1 to create a new BetterTransformerBaseLayer object  with example: obj = BetterTransformerBaseLayer(config)