docstr: ivy.Array instance method variant of
  ivy.scaled_dot_product_attention. This method simply wraps the
  function, and so the docstring for ivy.scaled_dot_product_attention
  also applies to this method with minimal changes.
  
  Parameters
  ----------
  self
      The queries input array. The shape of queries input array should be in
      *[batch_shape,num_queries,feat_dim]*. The queries input array should
      have the same size as keys and values.
  key
      The keys input array. The shape of keys input array should be in
      *[batch_shape,num_keys,feat_dim]*. The keys input array should have
      the same size as queries and values.
  value
      The values input array. The shape of values input should be in
      *[batch_shape,num_keys,feat_dim]*. The values input array should
      have the same size as queries and keys.
  scale
      The scale float value.
      The scale float value is used to scale the query-key pairs before softmax.
  mask
      The mask input array. The mask to apply to the query-key values.
      Default is None. The shape of mask input should be in
      *[batch_shape,num_queries,num_keys]*.
  dropout_p
      Specifies the dropout probability, if greater than 0.0, dropout is applied
  is_causal
      If true, assumes causal attention masking and errors if both `mask` and
      `is_causal` are set.
  training
      If True, dropout is used, otherwise dropout is not activated.
  out
      optional output array, for writing the result to. It must have a shape
      that the inputs broadcast to.
  
  Returns
  -------
  ret
      The output following application of scaled dot-product attention.
      The output array is the weighted sum produced by the attention score
      and value. The shape of output array is
      *[batch_shape,num_queries,feat_dim]* .
  
  Examples
  --------
  With :class:`ivy.Array` input:
  
  >>> q = ivy.array([[[0.2, 1.], [2.2, 3.],[4.4, 5.6]]])
  >>> k = ivy.array([[[0.6, 1.5], [2.4, 3.3],[4.2, 5.1]]])
  >>> v = ivy.array([[[0.4, 1.3], [2.2, 3.1],[4.3, 5.3]]])
  >>> result = ivy.scaled_dot_product_attention(q, k, v, scale=1, dropout_p=0.1,
  ...                                           is_causal=True, training=True)
  >>> print(result)
  ivy.array([[[0.40000001, 1.29999995],
              [2.19994521, 3.09994531],
              [4.30000019, 5.30000019]]])
  
  >>> q = ivy.array([[[0.2, 1.], [2.2, 3.],[4.4, 5.6]]])
  >>> k = ivy.array([[[0.6, 1.5], [2.4, 3.3],[4.2, 5.1]]])
  >>> v = ivy.array([[[0.4, 1.3], [2.2, 3.1],[4.3, 5.3]]])
  >>> mask = ivy.array([[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0],[0.0, 0.0, 0.0]]])
  >>> result = ivy.scaled_dot_product_attention(q,k,v,scale=1, mask=mask)
  >>> print(result)
  ivy.array([[[0.40000001, 1.29999995],
              [2.19994521, 3.09994531],
              [4.30000019, 5.30000019]]])
  
  >>> q = ivy.array([[[0.2, 1.], [2.2, 3.], [4.4, 5.6]]])
  >>> k = ivy.array([[[0.6, 1.5], [2.4, 3.3], [4.2, 5.1]]])
  >>> v = ivy.array([[[0.4, 1.3], [2.2, 3.1], [4.3, 5.3]]])
  >>> out = ivy.zeros(shape=(1, 3, 2))
  >>> ivy.scaled_dot_product_attention(q, k, v, scale=1, dropout_p=0.1,
  ...                                  is_causal=True, training=True, out=out)
  >>> print(out)
  ivy.array([[[0.40000001, 1.29999995],
              [2.19994521, 3.09994531],
              [4.30000019, 5.30000019]]])
docstr_tok: ["ivy.Array","instance","method","variant","of","ivy.scaled_dot_product_attention",".","This","method","simply","wraps","the","function",",","and","so","the","docstring","for","ivy.scaled_dot_product_attention","also","applies","to","this","method","with","minimal","changes",".","Parameters","--","--","--","--","--","self","The","queries","input","array",".","The","shape","of","queries","input","array","should","be","in","*","[","batch_shape",",","num_queries",",","feat_dim","]","*",".","The","queries","input","array","should","have","the","same","size","as","keys","and","values",".","key","The","keys","input","array",".","The","shape","of","keys","input","array","should","be","in","*","[","batch_shape",",","num_keys",",","feat_dim","]","*",".","The","keys","input","array","should","have","the","same","size","as","queries","and","values",".","value","The","values","input","array",".","The","shape","of","values","input","should","be","in","*","[","batch_shape",",","num_keys",",","feat_dim","]","*",".","The","values","input","array","should","have","the","same","size","as","queries","and","keys",".","scale","The","scale","float","value",".","The","scale","float","value","is","used","to","scale","the","query-key","pairs","before","softmax",".","mask","The","mask","input","array",".","The","mask","to","apply","to","the","query-key","values",".","Default","is","None",".","The","shape","of","mask","input","should","be","in","*","[","batch_shape",",","num_queries",",","num_keys","]","*",".","dropout_p","Specifies","the","dropout","probability",",","if","greater","than","0.0",",","dropout","is","applied","is_causal","If","true",",","assumes","causal","attention","masking","and","errors","if","both","`","mask","`","and","`","is_causal","`","are","set",".","training","If","True",",","dropout","is","used",",","otherwise","dropout","is","not","activated",".","out","optional","output","array",",","for","writing","the","result","to",".","It","must","have","a","shape","that","the","inputs","broadcast","to",".","Returns","--","--","--","-","ret","The","output","following","application","of","scaled","dot-product","attention",".","The","output","array","is","the","weighted","sum","produced","by","the","attention","score","and","value",".","The","shape","of","output","array","is","*","[","batch_shape",",","num_queries",",","feat_dim","]","*",".","Examples","--","--","--","--","With",":","class",":","`","ivy.Array","`","input",":",">",">",">","q","=","ivy.array","(","[","[","[","0.2",",","1",".","]",",","[","2.2",",","3",".","]",",","[","4.4",",","5.6","]","]","]",")",">",">",">","k","=","ivy.array","(","[","[","[","0.6",",","1.5","]",",","[","2.4",",","3.3","]",",","[","4.2",",","5.1","]","]","]",")",">",">",">","v","=","ivy.array","(","[","[","[","0.4",",","1.3","]",",","[","2.2",",","3.1","]",",","[","4.3",",","5.3","]","]","]",")",">",">",">","result","=","ivy.scaled_dot_product_attention","(","q",",","k",",","v",",","scale=1",",","dropout_p=0.1",",","...","is_causal=True",",","training=True",")",">",">",">","print","(","result",")","ivy.array","(","[","[","[","0.40000001",",","1.29999995","]",",","[","2.19994521",",","3.09994531","]",",","[","4.30000019",",","5.30000019","]","]","]",")",">",">",">","q","=","ivy.array","(","[","[","[","0.2",",","1",".","]",",","[","2.2",",","3",".","]",",","[","4.4",",","5.6","]","]","]",")",">",">",">","k","=","ivy.array","(","[","[","[","0.6",",","1.5","]",",","[","2.4",",","3.3","]",",","[","4.2",",","5.1","]","]","]",")",">",">",">","v","=","ivy.array","(","[","[","[","0.4",",","1.3","]",",","[","2.2",",","3.1","]",",","[","4.3",",","5.3","]","]","]",")",">",">",">","mask","=","ivy.array","(","[","[","[","0.0",",","0.0",",","0.0","]",",","[","0.0",",","0.0",",","0.0","]",",","[","0.0",",","0.0",",","0.0","]","]","]",")",">",">",">","result","=","ivy.scaled_dot_product_attention","(","q",",","k",",","v",",","scale=1",",","mask=mask",")",">",">",">","print","(","result",")","ivy.array","(","[","[","[","0.40000001",",","1.29999995","]",",","[","2.19994521",",","3.09994531","]",",","[","4.30000019",",","5.30000019","]","]","]",")",">",">",">","q","=","ivy.array","(","[","[","[","0.2",",","1",".","]",",","[","2.2",",","3",".","]",",","[","4.4",",","5.6","]","]","]",")",">",">",">","k","=","ivy.array","(","[","[","[","0.6",",","1.5","]",",","[","2.4",",","3.3","]",",","[","4.2",",","5.1","]","]","]",")",">",">",">","v","=","ivy.array","(","[","[","[","0.4",",","1.3","]",",","[","2.2",",","3.1","]",",","[","4.3",",","5.3","]","]","]",")",">",">",">","out","=","ivy.zeros","(","shape=","(","1",",","3",",","2",")",")",">",">",">","ivy.scaled_dot_product_attention","(","q",",","k",",","v",",","scale=1",",","dropout_p=0.1",",","...","is_causal=True",",","training=True",",","out=out",")",">",">",">","print","(","out",")","ivy.array","(","[","[","[","0.40000001",",","1.29999995","]",",","[","2.19994521",",","3.09994531","]",",","[","4.30000019",",","5.30000019","]","]","]",")"]
code: def scaled_dot_product_attention(
      self: ivy.Array,
      key: Union[ivy.Array, ivy.NativeArray],
      value: Union[ivy.Array, ivy.NativeArray],
      /,
      *,
      scale: Optional[float] = None,
      mask: Optional[Union[ivy.Array, ivy.NativeArray]] = None,
      dropout_p: Optional[float] = 0.0,
      is_causal: Optional[bool] = False,
      training: Optional[bool] = False,
      out: Optional[ivy.Array] = None,
  ) -> ivy.Array:
      """ivy.Array instance method variant of
      ivy.scaled_dot_product_attention. This method simply wraps the
      function, and so the docstring for ivy.scaled_dot_product_attention
      also applies to this method with minimal changes.
  
      Parameters
      ----------
      self
          The queries input array. The shape of queries input array should be in
          *[batch_shape,num_queries,feat_dim]*. The queries input array should
          have the same size as keys and values.
      key
          The keys input array. The shape of keys input array should be in
          *[batch_shape,num_keys,feat_dim]*. The keys input array should have
          the same size as queries and values.
      value
          The values input array. The shape of values input should be in
          *[batch_shape,num_keys,feat_dim]*. The values input array should
          have the same size as queries and keys.
      scale
          The scale float value.
          The scale float value is used to scale the query-key pairs before softmax.
      mask
          The mask input array. The mask to apply to the query-key values.
          Default is None. The shape of mask input should be in
          *[batch_shape,num_queries,num_keys]*.
      dropout_p
          Specifies the dropout probability, if greater than 0.0, dropout is applied
      is_causal
          If true, assumes causal attention masking and errors if both `mask` and
          `is_causal` are set.
      training
          If True, dropout is used, otherwise dropout is not activated.
      out
          optional output array, for writing the result to. It must have a shape
          that the inputs broadcast to.
  
      Returns
      -------
      ret
          The output following application of scaled dot-product attention.
          The output array is the weighted sum produced by the attention score
          and value. The shape of output array is
          *[batch_shape,num_queries,feat_dim]* .
  
      Examples
      --------
      With :class:`ivy.Array` input:
  
      >>> q = ivy.array([[[0.2, 1.], [2.2, 3.],[4.4, 5.6]]])
      >>> k = ivy.array([[[0.6, 1.5], [2.4, 3.3],[4.2, 5.1]]])
      >>> v = ivy.array([[[0.4, 1.3], [2.2, 3.1],[4.3, 5.3]]])
      >>> result = ivy.scaled_dot_product_attention(q, k, v, scale=1, dropout_p=0.1,
      ...                                           is_causal=True, training=True)
      >>> print(result)
      ivy.array([[[0.40000001, 1.29999995],
                  [2.19994521, 3.09994531],
                  [4.30000019, 5.30000019]]])
  
      >>> q = ivy.array([[[0.2, 1.], [2.2, 3.],[4.4, 5.6]]])
      >>> k = ivy.array([[[0.6, 1.5], [2.4, 3.3],[4.2, 5.1]]])
      >>> v = ivy.array([[[0.4, 1.3], [2.2, 3.1],[4.3, 5.3]]])
      >>> mask = ivy.array([[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0],[0.0, 0.0, 0.0]]])
      >>> result = ivy.scaled_dot_product_attention(q,k,v,scale=1, mask=mask)
      >>> print(result)
      ivy.array([[[0.40000001, 1.29999995],
                  [2.19994521, 3.09994531],
                  [4.30000019, 5.30000019]]])
  
      >>> q = ivy.array([[[0.2, 1.], [2.2, 3.], [4.4, 5.6]]])
      >>> k = ivy.array([[[0.6, 1.5], [2.4, 3.3], [4.2, 5.1]]])
      >>> v = ivy.array([[[0.4, 1.3], [2.2, 3.1], [4.3, 5.3]]])
      >>> out = ivy.zeros(shape=(1, 3, 2))
      >>> ivy.scaled_dot_product_attention(q, k, v, scale=1, dropout_p=0.1,
      ...                                  is_causal=True, training=True, out=out)
      >>> print(out)
      ivy.array([[[0.40000001, 1.29999995],
                  [2.19994521, 3.09994531],
                  [4.30000019, 5.30000019]]])
      """
      return ivy.scaled_dot_product_attention(
          self._data,
          key,
          value,
          scale=scale,
          mask=mask,
          dropout_p=dropout_p,
          is_causal=is_causal,
          training=training,
          out=out,
      )
  
file_path: ivy/ivy/data_classes/array/layers.py
imports: import abc
  from typing import Optional, Tuple, Union, List, Sequence
  import ivy
label_desc: Use image node_id 6 for calling the _ArrayWithLayers obj's underlying member method code with example usage: obj.scaled_dot_product_attention() and returns: ivy