docstr: Processes a projected query and key-value pair to apply
  scaled dot product attention.
  Args:
      dropout (float): probability of dropping an attention weight.
  Examples::
      >>> SDP = torchtext.models.ScaledDotProduct(0.1)
      >>> q = torch.randn(256, 21, 3)
      >>> k = v = torch.randn(256, 21, 3)
      >>> attn_output, attn_weights = SDP(q, k, v)
      >>> print(attn_output.shape, attn_weights.shape)
      torch.Size([256, 21, 3]) torch.Size([256, 21, 21])
docstr_tok: ["Processes","a","projected","query","and","key-value","pair","to","apply","scaled","dot","product","attention",".","Args",":","dropout","(","float",")",":","probability","of","dropping","an","attention","weight",".","Examples",":",":",">",">",">","SDP","=","torchtext.models.ScaledDotProduct","(","0.1",")",">",">",">","q","=","torch.randn","(","256",",","21",",","3",")",">",">",">","k","=","v","=","torch.randn","(","256",",","21",",","3",")",">",">",">","attn_output",",","attn_weights","=","SDP","(","q",",","k",",","v",")",">",">",">","print","(","attn_output.shape",",","attn_weights.shape",")","torch.Size","(","[","256",",","21",",","3","]",")","torch.Size","(","[","256",",","21",",","21","]",")"]
code: def __init__(self, dropout=0.0):
      r"""Processes a projected query and key-value pair to apply
      scaled dot product attention.
      Args:
          dropout (float): probability of dropping an attention weight.
      Examples::
          >>> SDP = torchtext.models.ScaledDotProduct(0.1)
          >>> q = torch.randn(256, 21, 3)
          >>> k = v = torch.randn(256, 21, 3)
          >>> attn_output, attn_weights = SDP(q, k, v)
          >>> print(attn_output.shape, attn_weights.shape)
          torch.Size([256, 21, 3]) torch.Size([256, 21, 21])
      """
      super().__init__()
      self.dropout = dropout
  
imports: import math
  from collections import OrderedDict
  from typing import Optional, Tuple
  import torch
  import torch.nn.functional
  from torch import nn, Tensor
label_desc: Use image node_id 1 to create a new ScaledDotProduct object from inherited base classes: torch.nn with example: obj = ScaledDotProduct(dropout)