code: def bark_wrapped_scaled_dot_product(
      self,
      query: torch.Tensor,
      key: torch.Tensor,
      value: torch.Tensor,
      attention_mask: Optional[torch.Tensor] = None,
      head_mask: Optional[torch.Tensor] = None,
  ):
      raise_on_head_mask(head_mask)
  
      # When `past_kv` is provided, we're doing incremental decoding and `q.shape[2] == 1`: q only contains
      # the query for the last token. scaled_dot_product_attention interprets this as the first token in the
      # sequence, so if is_causal=True it will mask out all attention from it. This is not what we want, so
      # to work around this we set is_causal=False.
      is_causal = self.is_causal and query.shape[2] != 1
  
      sdpa_result = torch.nn.functional.scaled_dot_product_attention(
          query,
          key,
          value,
          attn_mask=None,
          dropout_p=self.dropout if self.training else 0.0,
          is_causal=is_causal,
      )
  
      return sdpa_result, None
  
file_path: optimum/optimum/bettertransformer/models/attention.py
imports: from typing import Optional, Tuple
  import torch
label_desc: Use image node_id 3 for calling a global function with example usage: bark_wrapped_scaled_dot_product(query, key, value, attention_mask, head_mask) and returns: sdpa_result,  None