code: def __init__(self, config, attention_type):
      super().__init__()
  
      max_positions = config.max_position_embeddings
      bias = torch.tril(
          torch.ones((max_positions, max_positions), dtype=torch.uint8)
      ).view(1, 1, max_positions, max_positions)
  
      # local causal self attention is a sliding window where each token can only attend to the previous
      # window_size tokens. This is implemented by updating the causal mask such that for each token
      # all other tokens are masked except the previous window_size tokens.
      if attention_type == "local":
          bias = torch.bitwise_xor(
              bias, torch.tril(bias, -config.window_size)
          )
  
      self.register_buffer("bias", bias)
      self.register_buffer("masked_bias", torch.tensor(-1e9))
  
      self.attn_dropout = nn.Dropout(float(config.attention_dropout))
      self.resid_dropout = nn.Dropout(float(config.resid_dropout))
  
      self.embed_dim = config.hidden_size
      self.num_heads = config.num_heads
      self.head_dim = self.embed_dim // self.num_heads
      if self.head_dim * self.num_heads != self.embed_dim:
          raise ValueError(
              f"embed_dim must be divisible by num_heads (got `embed_dim`: {self.embed_dim} and `num_heads`:"
              f" {self.num_heads})."
          )
  
      self.k_proj = nn.Linear(
          self.embed_dim, self.embed_dim, bias=False
      )
      self.v_proj = nn.Linear(
          self.embed_dim, self.embed_dim, bias=False
      )
      self.q_proj = nn.Linear(
          self.embed_dim, self.embed_dim, bias=False
      )
      self.out_proj = nn.Linear(
          self.embed_dim, self.embed_dim, bias=True
      )
  
imports: import os
  from typing import Optional, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
  from ...activations import ACT2FN
  from ...modeling_outputs import BaseModelOutputWithPast, BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentions, CausalLMOutputWithPast, SequenceClassifierOutputWithPast
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
  from .configuration_gpt_neo import GPTNeoConfig
label_desc: Use image node_id 1 to create a new GPTNeoSelfAttention object from inherited base classes: nn with example: obj = GPTNeoSelfAttention(config, attention_type)