class_docstr: Implementing the Scaled Dot-Product attention proposed in
  `Attention is all you need`_, Vaswani et al.
  
  .. _`Attention is all you need`: https://arxiv.org/abs/1706.03762v5
class_docstr_tok: ["Implementing","the","Scaled","Dot-Product","attention","proposed","in","`","Attention","is","all","you","need","`","_",",","Vaswani","et","al",".","..","_","`","Attention","is","all","you","need","`",":","https",":","\/\/arxiv.org\/abs\/1706.03762v5"]
code: def __init__(
      self,
      dropout: float = 0.0,
      causal: bool = False,
      seq_len: Optional[int] = None,
      to_seq_len: Optional[int] = None,
      *args,
      **kwargs,
  ):
      super().__init__()
  
      self.attn_drop = nn.Dropout(dropout, inplace=False)
      self.causal = causal
      self.seq_len = seq_len
  
      if causal and seq_len is not None:
          self.mask = AttentionMask.make_causal(seq_len, to_seq_len)
      else:
          self.mask = None
  
      # Properties specific to this attention mechanism
      self.supports_attention_mask = True
      self.supports_key_padding_mask = False
  
file_path: xformers/xformers/components/attention/scaled_dot_product.py
imports: import logging
  from dataclasses import dataclass
  from typing import Optional, Union
  import torch
  from torch import nn
  from xformers.components.attention import Attention, AttentionConfig, AttentionMask, register_attention
  from xformers.components.attention.core import scaled_dot_product_attention
label_desc: Use image node_id 1 to create a new ScaledDotProduct object from inherited base classes: Attention with example: obj = ScaledDotProduct(dropout, causal, seq_len, to_seq_len)