class_docstr: Encoder only multi-head dot-product self-attention based on Performer.
  
  based on: https://arxiv.org/abs/2009.14794
  
  Attributes:
    num_heads: Number of attention heads. Features (i.e. inputs_q.shape[-1])
      should be divisible by the number of heads.
    qkv_features: Dimension of the key, query, and value.
    out_features: Dimension of the last projection.
    broadcast_dropout: Use a broadcasted dropout along batch dims.
    dropout_rate: Dropout rate.
    kernel_init: Initializer for the kernel of the Dense layers.
    bias_init: Initializer for the bias of the Dense layers.
    use_bias: Whether pointwise QKVO dense transforms use bias.
    dtype: The dtype of the computation.
    precision: Numerical precision of the computation see `jax.lax.Precision`
      for details.
    attention_fn_cls: Name of the attention function that is used by performer,
      which can be 'softmax' or 'generalized'.
    num_kernel_features: Number of kernel features.
    redraw: Whether to redraw (valid only if random featurees are used).
    attention_fn_configs: Configurations that is passed to the performer
      attention function.
class_docstr_tok: ["Encoder","only","multi-head","dot-product","self-attention","based","on","Performer",".","based","on",":","https",":","\/\/arxiv.org\/abs\/2009.14794","Attributes",":","num_heads",":","Number","of","attention","heads",".","Features","(","i.e",".","inputs_q.shape","[","-1","]",")","should","be","divisible","by","the","number","of","heads",".","qkv_features",":","Dimension","of","the","key",",","query",",","and","value",".","out_features",":","Dimension","of","the","last","projection",".","broadcast_dropout",":","Use","a","broadcasted","dropout","along","batch","dims",".","dropout_rate",":","Dropout","rate",".","kernel_init",":","Initializer","for","the","kernel","of","the","Dense","layers",".","bias_init",":","Initializer","for","the","bias","of","the","Dense","layers",".","use_bias",":","Whether","pointwise","QKVO","dense","transforms","use","bias",".","dtype",":","The","dtype","of","the","computation",".","precision",":","Numerical","precision","of","the","computation","see","`","jax.lax.Precision","`","for","details",".","attention_fn_cls",":","Name","of","the","attention","function","that","is","used","by","performer",",","which","can","be","'softmax","'","or","'generalized","'",".","num_kernel_features",":","Number","of","kernel","features",".","redraw",":","Whether","to","redraw","(","valid","only","if","random","featurees","are","used",")",".","attention_fn_configs",":","Configurations","that","is","passed","to","the","performer","attention","function","."]
docstr: Applies multi-head dot product self-attention on the input data.
  
  Projects the inputs into multi-headed query, key, and value vectors,
  applies dot-product attention and project the results to an output vector.
  
  Args:
    inputs_q: Input of shape `[batch_sizes..., length, features]`.
    inputs_kv: Memory input of shape `[batch_sizes..., kv length, features]`.
    deterministic: Whether the model is running in deterministic mode (if so,
      do not apply dropout).
  
  Returns:
    Output of shape `[batch_sizes..., length features]`.
code: def __call__(
      self,
      inputs_q: jnp.ndarray,
      inputs_kv: Optional[jnp.ndarray],
      *,
      deterministic: bool,
  ) -> jnp.ndarray:
      """Applies multi-head dot product self-attention on the input data.
  
      Projects the inputs into multi-headed query, key, and value vectors,
      applies dot-product attention and project the results to an output vector.
  
      Args:
        inputs_q: Input of shape `[batch_sizes..., length, features]`.
        inputs_kv: Memory input of shape `[batch_sizes..., kv length, features]`.
        deterministic: Whether the model is running in deterministic mode (if so,
          do not apply dropout).
  
      Returns:
        Output of shape `[batch_sizes..., length features]`.
      """
      qkv_features = self.qkv_features or inputs_q.shape[-1]
      assert (
          qkv_features % self.num_heads == 0
      ), "Memory dimension must be divisible by number of heads."
      if self.attention_fn_cls == "softmax":
          qk_attention_fn = functools.partial(
              make_fast_softmax_attention,
              nb_features=self.num_kernel_features,
              redraw_features=self.redraw,
          )
      elif self.attention_fn_cls == "generalized":
          qk_attention_fn = make_fast_generalized_attention
      else:
          raise ValueError(
              f"Unknown attention_fn_cls: {self.attention_fn_cls}."
          )
  
      qk_attention_fn = (
          qk_attention_fn
          if self.attention_fn_configs is None
          else functools.partial(
              qk_attention_fn, **self.attention_fn_configs
          )
      )  # pylint: disable=not-a-mapping
  
      return attention_layers.MultiHeadAttention(
          num_heads=self.num_heads,
          qkv_features=qkv_features,
          out_features=self.out_features,
          broadcast_dropout=self.broadcast_dropout,
          dropout_rate=self.dropout_rate,
          kernel_init=self.kernel_init,
          bias_init=self.bias_init,
          use_bias=self.use_bias,
          dtype=self.dtype,
          precision=self.precision,
          attention_fn=qk_attention_fn(
              qkv_features // self.num_heads, unidirectional=False
          ),
      )(
          inputs_q=inputs_q,
          inputs_kv=inputs_kv,
          deterministic=deterministic,
      )
  
imports: import abc
  import enum
  import functools
  from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Iterable
  from absl import logging
  from flax import linen
  import jax
  from jax import lax
  from jax import random
  import jax.numpy
  import numpy
  from scenic.model_lib.layers import attention_layers
label_desc: Use image node_id 1 for calling the PerformerEncoderAttention obj's underlying member method code with example usage: obj.__call__(inputs_q, inputs_kv) and returns: attention_layers