(d_feature, n_heads=1, sparsity=None,
                                  dropout=0.0, max_inference_length=2048,
                                  mode='train')
return tl.ConfigurableAttention(
      FactoredDense(sparsity, d_feature, d_feature),
      FactoredDense(sparsity, d_feature, d_feature),
      FactoredDense(sparsity, d_feature, d_feature),
      FactoredDense(sparsity, d_feature, d_feature),
      n_heads=n_heads, qkv_attention_layer=tl.DotProductCausalAttention(
          dropout=dropout, max_inference_length=max_inference_length,
          mode=mode))
Returns a layer that maps activations to activations, with causal masking.

  Like `CausalAttention`, this layer type represents one pass of multi-head
  self-attention with causal masking rather than padding-based masking. However,
  for computing Q/K/V instead of a Dense layer it multiplies each embedding
  dimension by a scalar specific to each dimension and each head; then it
  produces Q/K/V by applying the same dense layer to each head. In comparison
  to standard dense layer for computing Q/K/V, this layer uses less parameters
  while still being able to express many functions, like a permutation.

  Args:
    d_feature: Depth/dimensionality of feature embedding.
    n_heads: Number of attention heads.
    sparsity: The sparsity of the layer; usually it should be equal to n_heads.
    dropout: Probababilistic rate for internal dropout applied to attention
        activations (based on query-key pairs) before dotting them with values.
    max_inference_length: maximum length for inference.
    mode: One of `'train'`, `'eval'`, or `'predict'`.
Returns a layer that maps activations to activations, with causal masking.
Returns a layer that maps activations to activations with causal masking .
def MultiplicativeCausalAttention(d_feature, n_heads=1, sparsity=None,
                                  dropout=0.0, max_inference_length=2048,
                                  mode='train'):
  """Returns a layer that maps activations to activations, with causal masking.

  Like `CausalAttention`, this layer type represents one pass of multi-head
  self-attention with causal masking rather than padding-based masking. However,
  for computing Q/K/V instead of a Dense layer it multiplies each embedding
  dimension by a scalar specific to each dimension and each head; then it
  produces Q/K/V by applying the same dense layer to each head. In comparison
  to standard dense layer for computing Q/K/V, this layer uses less parameters
  while still being able to express many functions, like a permutation.

  Args:
    d_feature: Depth/dimensionality of feature embedding.
    n_heads: Number of attention heads.
    sparsity: The sparsity of the layer; usually it should be equal to n_heads.
    dropout: Probababilistic rate for internal dropout applied to attention
        activations (based on query-key pairs) before dotting them with values.
    max_inference_length: maximum length for inference.
    mode: One of `'train'`, `'eval'`, or `'predict'`.
  """
  sparsity = n_heads if sparsity is None else sparsity
  return tl.ConfigurableAttention(
      FactoredDense(sparsity, d_feature, d_feature),
      FactoredDense(sparsity, d_feature, d_feature),
      FactoredDense(sparsity, d_feature, d_feature),
      FactoredDense(sparsity, d_feature, d_feature),
      n_heads=n_heads, qkv_attention_layer=tl.DotProductCausalAttention(
          dropout=dropout, max_inference_length=max_inference_length,
          mode=mode))
def MultiplicativeCausalAttention ( d_feature , n_heads = 1 , sparsity = None , dropout = 0.0 , max_inference_length = 2048 , mode = 'train' ) : sparsity = n_heads if sparsity is None else sparsity return tl . ConfigurableAttention ( FactoredDense ( sparsity , d_feature , d_feature ) , FactoredDense ( sparsity , d_feature , d_feature ) , FactoredDense ( sparsity , d_feature , d_feature ) , FactoredDense ( sparsity , d_feature , d_feature ) , n_heads = n_heads , qkv_attention_layer = tl . DotProductCausalAttention ( dropout = dropout , max_inference_length = max_inference_length , mode = mode ) )