class_docstr: BERT self-attention layer from Huggingface transformers.
  
  Compared to the BertSelfAttention of Huggingface, only add the clamp.
  
  Args:
      config (:class:`~transformers.BertConfig`):
          The configuration object that
          contains various parameters for the model.
      clamp_min_for_underflow (bool, optional):
          Whether to clamp the minimum value of the hidden states
           to prevent underflow. Defaults to `False`.
      clamp_max_for_overflow (bool, optional):
          Whether to clamp the maximum value of the hidden states
          to prevent overflow. Defaults to `False`.
class_docstr_tok: ["BERT","self-attention","layer","from","Huggingface","transformers",".","Compared","to","the","BertSelfAttention","of","Huggingface",",","only","add","the","clamp",".","Args",":","config","(",":","class",":","`","~transformers.BertConfig","`",")",":","The","configuration","object","that","contains","various","parameters","for","the","model",".","clamp_min_for_underflow","(","bool",",","optional",")",":","Whether","to","clamp","the","minimum","value","of","the","hidden","states","to","prevent","underflow",".","Defaults","to","`","False","`",".","clamp_max_for_overflow","(","bool",",","optional",")",":","Whether","to","clamp","the","maximum","value","of","the","hidden","states","to","prevent","overflow",".","Defaults","to","`","False","`","."]
code: def __init__(
      self,
      config: BertConfig,
      clamp_min_for_underflow: bool = False,
      clamp_max_for_overflow: bool = False,
  ):
      super().__init__()
      if (
          config.hidden_size % config.num_attention_heads != 0
          and not hasattr(config, "embedding_size")
      ):
          raise ValueError(
              f"The hidden size ({config.hidden_size}) is "
              "not a multiple of the number of attention "
              f"heads ({config.num_attention_heads})"
          )
  
      self.num_attention_heads = config.num_attention_heads
      self.attention_head_size = int(
          config.hidden_size / config.num_attention_heads
      )
      self.all_head_size = (
          self.num_attention_heads * self.attention_head_size
      )
  
      self.query = nn.Linear(config.hidden_size, self.all_head_size)
      self.key = nn.Linear(config.hidden_size, self.all_head_size)
      self.value = nn.Linear(config.hidden_size, self.all_head_size)
  
      self.dropout = nn.Dropout(config.attention_probs_dropout_prob)
      self.position_embedding_type = getattr(
          config, "position_embedding_type", "absolute"
      )
      if (
          self.position_embedding_type == "relative_key"
          or self.position_embedding_type == "relative_key_query"
      ):
          self.max_position_embeddings = config.max_position_embeddings
          self.distance_embedding = nn.Embedding(
              2 * config.max_position_embeddings - 1,
              self.attention_head_size,
          )
      self.clamp_min_for_underflow = clamp_min_for_underflow
      self.clamp_max_for_overflow = clamp_max_for_overflow
  
      self.is_decoder = config.is_decoder
  
imports: import math
  from typing import Dict, Optional, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils.checkpoint
  from mmcv.cnn.bricks import DropPath
  from torch import Tensor
label_desc: Use image node_id 1 to create a new BertSelfAttention object from inherited base classes: nn with example: obj = BertSelfAttention(config, clamp_min_for_underflow, clamp_max_for_overflow)