code: def __init__(self, config, position_embedding_type=None):
      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.q_proj = nn.Linear(config.hidden_size, self.all_head_size)
      self.k_proj = nn.Linear(config.hidden_size, self.all_head_size)
      self.v_proj = nn.Linear(config.hidden_size, self.all_head_size)
  
      self.dropout = nn.Dropout(config.attention_probs_dropout_prob)
      self.position_embedding_type = position_embedding_type or 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.is_decoder = config.is_decoder
  
imports: import math
  from typing import List, Optional, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn, tensor
  from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
  from ...activations import ACT2FN
  from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, BaseModelOutputWithPoolingAndCrossAttentions, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
  from ...modeling_utils import PreTrainedModel
  from ...pytorch_utils import find_pruneable_heads_and_indices, prune_linear_layer
  from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
  from .configuration_ernie_m import ErnieMConfig
label_desc: Use image node_id 1 to create a new ErnieMSelfAttention object from inherited base classes: nn with example: obj = ErnieMSelfAttention(config, position_embedding_type)