class_docstr: Transformer encoder layer.
  
  Attributes:
    mlp_dim: Dimension of the mlp on top of attention block.
    num_heads: Number of self-attention heads.
    dtype: The dtype of the computation (default: float32).
    dropout_rate: Dropout rate.
    attention_dropout_rate: Dropout for attention heads.
  
  Returns:
    output after transformer encoder block.
class_docstr_tok: ["Transformer","encoder","layer",".","Attributes",":","mlp_dim",":","Dimension","of","the","mlp","on","top","of","attention","block",".","num_heads",":","Number","of","self-attention","heads",".","dtype",":","The","dtype","of","the","computation","(","default",":","float32",")",".","dropout_rate",":","Dropout","rate",".","attention_dropout_rate",":","Dropout","for","attention","heads",".","Returns",":","output","after","transformer","encoder","block","."]
docstr: Generate the drop-layer mask.
  
  Args:
    x: Input tensor.
    deterministic: Weather we are in the deterministic mode (e.g inference
      time) or not.
    droplayer_p: Probability of dropping a layer.
  
  Returns:
    Droplayer mask.
docstr_tok: ["Generate","the","drop-layer","mask",".","Args",":","x",":","Input","tensor",".","deterministic",":","Weather","we","are","in","the","deterministic","mode","(","e.g","inference","time",")","or","not",".","droplayer_p",":","Probability","of","dropping","a","layer",".","Returns",":","Droplayer","mask","."]
code: def get_droplayer_mask(
      self,
      x: jnp.ndarray,
      deterministic: bool,
      droplayer_p: Optional[float],
  ) -> jnp.ndarray:
      """Generate the drop-layer mask.
  
      Args:
        x: Input tensor.
        deterministic: Weather we are in the deterministic mode (e.g inference
          time) or not.
        droplayer_p: Probability of dropping a layer.
  
      Returns:
        Droplayer mask.
      """
      if not deterministic and droplayer_p is not None:
          shape = (x.shape[0],) + (1,) * (x.ndim - 1)
          return jax.random.bernoulli(
              self.make_rng("dropout"), droplayer_p, shape
          )
      else:
          return 0.0
  
imports: import functools
  from typing import Any, Callable, Optional, Sequence, Tuple, Union
  import flax.linen
  import jax
  from jax.nn import initializers
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.model_lib.layers import attention_layers
  from scenic.model_lib.layers import nn_layers
  from scenic.projects.baselines import vit
  from scenic.projects.polyvit import polyvit_base_model
  from scenic.projects.vivit import model
label_desc: Use image node_id 1 for calling the Encoder1DBlock obj's underlying member method code with example usage: obj.get_droplayer_mask(x, deterministic, droplayer_p) and returns: jax, int