(self, inputs)
return merged_results, mask
Returns attention-computed activations and unmodified mask.

    Args:
      inputs: A (location_bias, context_bias, pos_emb, q, k, v, mask) tuple.
Returns attention-computed activations and unmodified mask.
Returns attention - computed activations and unmodified mask .
def forward(self, inputs):
    """Returns attention-computed activations and unmodified mask.

    Args:
      inputs: A (location_bias, context_bias, pos_emb, q, k, v, mask) tuple.
    """
    location_bias, context_bias, pos_emb, q, k, v, mask = inputs

    d_feature = q.shape[-1]
    n_heads = self._n_heads
    if d_feature % n_heads != 0:
      raise ValueError(
          f'Dimensionality of feature embedding ({d_feature}) is not a '
          f'multiple of the requested number of attention heads ({n_heads}).')

    per_head_results, dots = DotProductAttention(
        SplitIntoHeads(n_heads, merged_batch_and_head=False).forward(q),
        SplitIntoHeads(n_heads, merged_batch_and_head=False).forward(k),
        SplitIntoHeads(n_heads, merged_batch_and_head=False).forward(v),
        pos_emb.reshape((-1, n_heads, d_feature // n_heads)),
        context_bias,
        location_bias,
        mask,
        separate_cls=self._separate_cls,
        dropout=self._dropout,
        mode=self._mode,
        rng=self.rng)
    if self._mode == 'viz':
      self.state = dots
    merged_results = MergeHeads(
        n_heads, merged_batch_and_head=False).forward(per_head_results)
    return merged_results, mask
def forward ( self , inputs ) : location_bias , context_bias , pos_emb , q , k , v , mask = inputs d_feature = q . shape [ - 1 ] n_heads = self . _n_heads if d_feature % n_heads != 0 : raise ValueError ( f'Dimensionality of feature embedding ({d_feature}) is not a ' f'multiple of the requested number of attention heads ({n_heads}).' ) per_head_results , dots = DotProductAttention ( SplitIntoHeads ( n_heads , merged_batch_and_head = False ) . forward ( q ) , SplitIntoHeads ( n_heads , merged_batch_and_head = False ) . forward ( k ) , SplitIntoHeads ( n_heads , merged_batch_and_head = False ) . forward ( v ) , pos_emb . reshape ( ( - 1 , n_heads , d_feature // n_heads ) ) , context_bias , location_bias , mask , separate_cls = self . _separate_cls , dropout = self . _dropout , mode = self . _mode , rng = self . rng ) if self . _mode == 'viz' : self . state = dots merged_results = MergeHeads ( n_heads , merged_batch_and_head = False ) . forward ( per_head_results ) return merged_results , mask