class_docstr: Calculate the attention weights.
  q, k, v must have matching leading dimensions.
  k, v must have matching penultimate dimension, i.e.: seq_len_k = seq_len_v.
  The mask has different shapes depending on its type(padding or look ahead)
  but it must be broadcastable for addition.
  
  Args:
      q: query shape == (..., seq_len_q, depth)
      k: key shape == (..., seq_len_k, depth)
      v: value shape == (..., seq_len_v, depth_v)
      mask: Float tensor with shape broadcastable
        to (..., seq_len_q, seq_len_k). Defaults to None.
  
  Returns:
      output, attention_weights
class_docstr_tok: ["Calculate","the","attention","weights",".","q",",","k",",","v","must","have","matching","leading","dimensions",".","k",",","v","must","have","matching","penultimate","dimension",",","i.e",".",":","seq_len_k","=","seq_len_v",".","The","mask","has","different","shapes","depending","on","its","type","(","padding","or","look","ahead",")","but","it","must","be","broadcastable","for","addition",".","Args",":","q",":","query","shape","==","(","...",",","seq_len_q",",","depth",")","k",":","key","shape","==","(","...",",","seq_len_k",",","depth",")","v",":","value","shape","==","(","...",",","seq_len_v",",","depth_v",")","mask",":","Float","tensor","with","shape","broadcastable","to","(","...",",","seq_len_q",",","seq_len_k",")",".","Defaults","to","None",".","Returns",":","output",",","attention_weights"]
docstr: This is where the layer's logic lives.
docstr_tok: ["This","is","where","the","layer","'s","logic","lives","."]
code: def call(self, q, k, v, mask):
      """This is where the layer's logic lives."""
      matmul_qk = tf.matmul(
          q, k, transpose_b=True
      )  # (..., seq_len_q, seq_len_k)
  
      # scale matmul_qk
      dk = tf.cast(tf.shape(k)[-1], tf.float32)
      scaled_attention_logits = matmul_qk / tf.math.sqrt(dk)
  
      # add the mask to the scaled tensor.
      if mask is not None:
          scaled_attention_logits += mask * -1e9
  
      # softmax is normalized on the last axis (seq_len_k) so that the scores
      # add up to 1.
      # (..., seq_len_q, seq_len_k)
      attention_weights = tf.nn.softmax(
          scaled_attention_logits, axis=-1
      )
  
      output = tf.matmul(
          attention_weights, v
      )  # (..., seq_len_q, depth_v)
  
      return output, attention_weights
  
file_path: delta/gcompiler/example/python/tts_transformer/model.py
imports: import numpy
  import tensorflow
  import delta_infer
  from tts_transformer.model import *
label_desc: Use image node_id 1 for calling the ScaledDotProductAttention obj's underlying member method code with example usage: obj.call(q, k, v, mask) and returns: output,  attention_weights