class_docstr: The same as ViViT Transformer encoder block. Supports masked tokens.
docstr: Applies Encoder1DBlock module.
docstr_tok: ["Applies","Encoder1DBlock","module","."]
code: def __call__(
      self,
      inputs: jnp.ndarray,
      deterministic: bool,
      empty_mask: Optional[jnp.ndarray] = None,
  ) -> jnp.ndarray:
      """Applies Encoder1DBlock module."""
  
      # Expanding object mask to pairwise attention masks. This is used in
      #  factorized-encoder models where removing tokens are hard.
      # empty_mask: B x L --> mask: B x 1 x L x L.
      #   The second dimention 1 will be broadcasted to num_heads
      mask = (
          None
          if empty_mask is None
          else empty_mask[..., None, None, :]
          * empty_mask[..., None, :, None]
      )
      # Attention block.
      x = nn.LayerNorm(dtype=self.dtype)(inputs)
      x = nn.MultiHeadDotProductAttention(
          num_heads=self.num_heads,
          kernel_init=self.attention_kernel_initializer,
          broadcast_dropout=False,
          dropout_rate=self.attention_dropout_rate,
          attention_fn=self.attention_fn,
          dtype=self.dtype,
      )(
          x, x, mask=mask, deterministic=deterministic
      )  # added mask here.
      x = nn.Dropout(rate=self.dropout_rate)(x, deterministic)
  
      drop_pattern = self.get_drop_pattern(x, deterministic)
      x = x * (1.0 - drop_pattern) + inputs
  
      # MLP block.
      y = nn.LayerNorm(dtype=self.dtype)(x)
      y = attention_layers.MlpBlock(  # pytype: disable=wrong-arg-types  # jnp-type
          mlp_dim=self.mlp_dim,
          dtype=self.dtype,
          dropout_rate=self.dropout_rate,
          activation_fn=functools.partial(
              nn.gelu, approximate=self.use_approximate_gelu
          ),
          kernel_init=self.mlp_kernel_initializer,
          bias_init=self.mlp_bias_initializer,
      )(
          y, deterministic=deterministic
      )
  
      drop_pattern = self.get_drop_pattern(x, deterministic)
      return y * (1.0 - drop_pattern) + x
  
imports: import functools
  from typing import Any, Callable, Iterable, Optional
  import flax.linen
  import jax
  import jax.numpy
  import ml_collections
  from scenic.model_lib.layers import attention_layers
  from scenic.projects.objectvivit.object_attention import ObjectBlock
label_desc: Use image node_id 2 for calling the CustomEncoderBlock obj's underlying member method code with example usage: obj.__call__(inputs, deterministic, empty_mask) and returns: unknown