class_docstr: Multi-Head Self-Attention Module.
  
  A kernel function of queries and keys, which is projection of sequence encodings
  
  Parameters
  ----------------
  d_hidden: int
      hidden size
  n_head: int
      number of attention heads
  n_enc_layer: int
      number of MLP hidden layers in query/key projections
  symmetric: bool, by default False
      if True, queries and keys are produced by a shared module
  share_values: bool, by default False
      if True, attention heads operate on the same value encodings
  dropout: float, by default 0.0
      dropout rate of normalized attention weights
  temperature: float, by default 1.0
      softmax temperature for attention weight normalization
  
  Args
  ------------------
  shape: Tensor [N, *, d_hidden]
      sequence encodings for queries and keys
  inter_value: Tensor [N, *, d_hidden] or [N, *, d_head]
      value encodings for interpolation
  extra_value: Tensor [N, *, d_hidden] or [N, *, d_head]
      value encodings for extrapolation
  mask: BoolTensor [N, *]
      mask over input sequence (1 for masked position)
code: def _compute_attn_output(
      self,
      score: Tensor,
      value: Tensor,
      dist_comp: Tensor,
  ) -> Tuple[Tensor, Tensor]:
      if self.share_values:
          assert value.size(2) == self.d_head
          value = pt.unsqueeze(value, dim=1)
      else:
          assert value.size(2) == self.d_hidden
          value = self._split_head(value)
      output = score @ value
      output = output + dist_comp
      output = self._merge_head(output)
      output = self.attn_norm(output)
      hidden = output
      for layer in range(self.n_dec_layer):
          hidden = F.linear(
              hidden,
              self._output_weights[layer],
              self._output_biases[layer],
          )
          if layer < self.n_dec_layer - 1:
              hidden = F.gelu(hidden)
              hidden = self.dropout(hidden)
          elif layer == self.n_dec_layer - 1:
              output = hidden + output
              output = self.dec_norm(output)
      return output
  
imports: from typing import Optional, List, Tuple, Union
  import math
  import numpy
  import torch
  from torch import Tensor, BoolTensor, nn
  from torch.nn import init, functional
  from tslib.nn.attention import Attention
  from tslib.nn.attention.posemb import SinusoidalPositionalEmbedding
label_desc: Use image node_id 5 for calling the AttentionKernel obj's underlying member method code with example usage: obj._compute_attn_output(score, value, dist_comp) and returns: output