class_docstr: A gated self-attention dense layer that combines visual features and object features.
  
  Parameters:
      query_dim (`int`): The number of channels in the query.
      context_dim (`int`): The number of channels in the context.
      n_heads (`int`): The number of heads to use for attention.
      d_head (`int`): The number of channels in each head.
class_docstr_tok: ["A","gated","self-attention","dense","layer","that","combines","visual","features","and","object","features",".","Parameters",":","query_dim","(","`","int","`",")",":","The","number","of","channels","in","the","query",".","context_dim","(","`","int","`",")",":","The","number","of","channels","in","the","context",".","n_heads","(","`","int","`",")",":","The","number","of","heads","to","use","for","attention",".","d_head","(","`","int","`",")",":","The","number","of","channels","in","each","head","."]
code: def __init__(
      self, query_dim: int, context_dim: int, n_heads: int, d_head: int
  ):
      super().__init__()
  
      # we need a linear projection since we need cat visual feature and obj feature
      self.linear = nn.Linear(context_dim, query_dim)
  
      self.attn = Attention(
          query_dim=query_dim, heads=n_heads, dim_head=d_head
      )
      self.ff = FeedForward(query_dim, activation_fn="geglu")
  
      self.norm1 = nn.LayerNorm(query_dim)
      self.norm2 = nn.LayerNorm(query_dim)
  
      self.register_parameter(
          "alpha_attn", nn.Parameter(torch.tensor(0.0))
      )
      self.register_parameter(
          "alpha_dense", nn.Parameter(torch.tensor(0.0))
      )
  
      self.enabled = True
  
imports: from typing import Any, Dict, Optional, Tuple
  import torch
  import torch.nn.functional
  from torch import nn
  from ..utils import USE_PEFT_BACKEND
  from ..utils.torch_utils import maybe_allow_in_graph
  from .activations import get_activation
  from .attention_processor import Attention
  from .embeddings import CombinedTimestepLabelEmbeddings
  from .lora import LoRACompatibleLinear
label_desc: Use image node_id 1 to create a new GatedSelfAttentionDense object from inherited base classes: nn with example: obj = GatedSelfAttentionDense(query_dim, context_dim, n_heads, d_head)