class_docstr: Multi-head attention layer for queries independent from keys/values.
  
  Parameters
  ----------
  att_dim_in
      Attention dimension (number of hidden units)
  heads
      Number of attention heads
  att_dim_out
      Output dimension (number of output units)
  dropout
      Dropout rate on attention scores
class_docstr_tok: ["Multi-head","attention","layer","for","queries","independent","from","keys\/values",".","Parameters","--","--","--","--","--","att_dim_in","Attention","dimension","(","number","of","hidden","units",")","heads","Number","of","attention","heads","att_dim_out","Output","dimension","(","number","of","output","units",")","dropout","Dropout","rate","on","attention","scores"]
docstr: Computes multi-head attention for queries given a memory tensor. If
  sequence lengths are provided, they will be used to mask the attention
  scores. A mask tensor may also be used to mask the attention scores.
  Returns a tensor of shape (batch_size, max_length, att_dim_out).
  
  Parameters
  ----------
  queries
      Queries tensor of shape (batch_size, query_max_length, att_dim_in)
  memory
      Memory tensor to attend to of shape (batch_size, memory_max_length,
      att_dim_in)
  mask
      Optional tensor to mask attention scores
  
  Returns
  -------
  Tensor of shape (batch_size, query_seq_len, att_dim_out)
docstr_tok: ["Computes","multi-head","attention","for","queries","given","a","memory","tensor",".","If","sequence","lengths","are","provided",",","they","will","be","used","to","mask","the","attention","scores",".","A","mask","tensor","may","also","be","used","to","mask","the","attention","scores",".","Returns","a","tensor","of","shape","(","batch_size",",","max_length",",","att_dim_out",")",".","Parameters","--","--","--","--","--","queries","Queries","tensor","of","shape","(","batch_size",",","query_max_length",",","att_dim_in",")","memory","Memory","tensor","to","attend","to","of","shape","(","batch_size",",","memory_max_length",",","att_dim_in",")","mask","Optional","tensor","to","mask","attention","scores","Returns","--","--","--","-","Tensor","of","shape","(","batch_size",",","query_seq_len",",","att_dim_out",")"]
code: def hybrid_forward(
      self,
      F,
      queries: Tensor,
      memory: Tensor,
      mask: Optional[Tensor] = None,
  ) -> Tensor:
      r"""
      Computes multi-head attention for queries given a memory tensor. If
      sequence lengths are provided, they will be used to mask the attention
      scores. A mask tensor may also be used to mask the attention scores.
      Returns a tensor of shape (batch_size, max_length, att_dim_out).
  
      Parameters
      ----------
      queries
          Queries tensor of shape (batch_size, query_max_length, att_dim_in)
      memory
          Memory tensor to attend to of shape (batch_size, memory_max_length,
          att_dim_in)
      mask
          Optional tensor to mask attention scores
  
      Returns
      -------
      Tensor of shape (batch_size, query_seq_len, att_dim_out)
      """
  
      # Q -> Q * W_q
      # K = V -> K * W_k, V * W_v
  
      # (batch, query_max_length, att_dim_in)
      queries = self.dense_pre_att_q(queries)
  
      # (batch, memory_max_length, att_dim_in)
      keys = self.dense_pre_att_k(memory)
  
      # (batch, memory_max_length, att_dim_in)
      values = self.dense_pre_att_v(memory)
  
      return self._attend(F, queries, keys, values, mask=mask)
  
imports: from typing import Dict, Optional, Tuple
  import mxnet
  from mxnet.gluon import HybridBlock
  from gluonts.mx import Tensor
label_desc: Use image node_id 2 for calling the MultiHeadAttention obj's underlying member method code with example usage: obj.hybrid_forward(F, queries, memory, mask) and returns: self