docstr: Multi-head scaled dot-product attention, a.k.a full attention.
  
  Args:
      queries: [N, L, H, D]
      keys: [N, S, H, D]
      values: [N, S, H, D]
      q_mask: [N, L]
      kv_mask: [N, S]
  Returns:
      queried_values: (N, L, H, D)
docstr_tok: ["Multi-head","scaled","dot-product","attention",",","a.k.a","full","attention",".","Args",":","queries",":","[","N",",","L",",","H",",","D","]","keys",":","[","N",",","S",",","H",",","D","]","values",":","[","N",",","S",",","H",",","D","]","q_mask",":","[","N",",","L","]","kv_mask",":","[","N",",","S","]","Returns",":","queried_values",":","(","N",",","L",",","H",",","D",")"]
code: def forward(
      self,
      queries: Tensor,
      keys: Tensor,
      values: Tensor,
      q_mask: Optional[Tensor] = None,
      kv_mask: Optional[Tensor] = None,
  ) -> Tensor:
      """Multi-head scaled dot-product attention, a.k.a full attention.
  
      Args:
          queries: [N, L, H, D]
          keys: [N, S, H, D]
          values: [N, S, H, D]
          q_mask: [N, L]
          kv_mask: [N, S]
      Returns:
          queried_values: (N, L, H, D)
      """
      # Compute the unnormalized attention and apply the masks
      QK = torch.einsum("nlhd,nshd->nlsh", queries, keys)
      if kv_mask is not None and q_mask is not None:
          QK.masked_fill_(
              ~(q_mask[:, :, None, None] * kv_mask[:, None, :, None]),
              float("-inf"),
          )
  
      # Compute the attention and the weighted average
      softmax_temp = 1.0 / queries.size(3) ** 0.5  # sqrt(D)
      A = torch.softmax(softmax_temp * QK, dim=2)
      if self.use_dropout:
          A = self.dropout(A)
  
      queried_values = torch.einsum("nlsh,nshd->nlhd", A, values)
  
      return queried_values.contiguous()
  
file_path: kornia/kornia/feature/loftr/loftr_module/linear_attention.py
imports: from typing import Optional
  import torch
  from torch.nn import Dropout
  from kornia.core import Module, Tensor
label_desc: Use image node_id 2 for calling the FullAttention obj's underlying member method code with example usage: obj.forward(queries, keys, values, q_mask, kv_mask) and returns: queried_values