code: def __init__(self, config: MgpstrConfig):
      super().__init__()
      self.num_heads = config.num_attention_heads
      head_dim = config.hidden_size // config.num_attention_heads
      self.scale = head_dim**-0.5
  
      self.qkv = nn.Linear(
          config.hidden_size,
          config.hidden_size * 3,
          bias=config.qkv_bias,
      )
      self.attn_drop = nn.Dropout(config.attn_drop_rate)
      self.proj = nn.Linear(config.hidden_size, config.hidden_size)
      self.proj_drop = nn.Dropout(config.drop_rate)
  
imports: import collections.abc
  from dataclasses import dataclass
  from typing import Optional, Tuple, Union
  import torch
  import torch.nn.functional
  import torch.utils.checkpoint
  from torch import nn
  from ...modeling_outputs import BaseModelOutput
  from ...modeling_utils import PreTrainedModel
  from ...utils import ModelOutput, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_mgp_str import MgpstrConfig
label_desc: Use image node_id 1 to create a new MgpstrAttention object from inherited base classes: nn with example: obj = MgpstrAttention(config)