class_docstr: The base Attention mechanism, which is typically a sub-part of the multi-head attention
class_docstr_tok: ["The","base","Attention","mechanism",",","which","is","typically","a","sub-part","of","the","multi-head","attention"]
code: def __init__(self, dropout: Optional[float] = None, *args, **kwargs):
      super().__init__()
  
      # Requires the inputs to be projected
      self.requires_input_projection = True
  
      # Whether the head dimension needs to be present (if not it can be folded into the batch dimension)
      self.requires_head_dimension = False
  
      # key padding mask and attention mask must be passed in as separate arguments instead of a merged attention mask
      self.requires_separate_masks = False
  
      # Requires that K and Q have the same sequence length
      self.requires_same_k_q_dimensions = False
  
      # Whether the attention owns the single head/multihead mechanism
      # so that the MHA wrapper should skip it
      self.requires_skip_multi_head = False
  
      # This attention requires a context length which is squared, often due to 2D pooling
      self.requires_squared_context = False
  
      # Whether this attention mechanism supports attention masks
      self.supports_attention_mask = True
      self.supports_key_padding_mask = False
  
file_path: xformers/xformers/components/attention/base.py
imports: from abc import ABCMeta, abstractmethod
  from dataclasses import asdict, dataclass
  from typing import Optional, Type, TypeVar
  import torch
  import torch.nn
  from xformers.components.attention import AttentionMask
label_desc: Use image node_id 1 to create a new Attention object from inherited base classes: nn with example: obj = Attention(dropout)