class_docstr: Create a dropout layer.
  
  Note: When using :meth:`Module.apply() <flax.linen.Module.apply>`, make sure
  to include an RNG seed named ``'dropout'``. Dropout isn't necessary for
  variable initialization. Example usage::
  
    >>> import flax.linen as nn
    >>> import jax, jax.numpy as jnp
  
    >>> class MLP(nn.Module):
    ...   @nn.compact
    ...   def __call__(self, x, train):
    ...     x = nn.Dense(4)(x)
    ...     x = nn.Dropout(0.5, deterministic=not train)(x)
    ...     return x
  
    >>> model = MLP()
    >>> x = jnp.ones((1, 3))
    >>> variables = model.init(jax.random.key(0), x, train=False) # don't use dropout
    >>> model.apply(variables, x, train=False) # don't use dropout
    Array([[-0.88686204, -0.5928178 , -0.5184689 , -0.4345976 ]], dtype=float32)
    >>> model.apply(variables, x, train=True, rngs={'dropout': jax.random.key(1)}) # use dropout
    Array([[ 0.       , -1.1856356, -1.0369378,  0.       ]], dtype=float32)
  
  Attributes:
    rate: the dropout probability.  (_not_ the keep rate!)
    broadcast_dims: dimensions that will share the same dropout mask
    deterministic: if false the inputs are scaled by ``1 / (1 - rate)`` and
      masked, whereas if true, no mask is applied and the inputs are returned as
      is.
    rng_collection: the rng collection name to use when requesting an rng key.
docstr: Applies a random dropout mask to the input.
  
  Args:
    inputs: the inputs that should be randomly masked.
    deterministic: if false the inputs are scaled by ``1 / (1 - rate)`` and
      masked, whereas if true, no mask is applied and the inputs are returned
      as is.
    rng: an optional PRNGKey used as the random key, if not specified, one
      will be generated using ``make_rng`` with the ``rng_collection`` name.
  
  Returns:
    The masked inputs reweighted to preserve mean.
docstr_tok: ["Applies","a","random","dropout","mask","to","the","input",".","Args",":","inputs",":","the","inputs","that","should","be","randomly","masked",".","deterministic",":","if","false","the","inputs","are","scaled","by","``","1","\/","(","1","-","rate",")","``","and","masked",",","whereas","if","true",",","no","mask","is","applied","and","the","inputs","are","returned","as","is",".","rng",":","an","optional","PRNGKey","used","as","the","random","key",",","if","not","specified",",","one","will","be","generated","using","``","make_rng","``","with","the","``","rng_collection","``","name",".","Returns",":","The","masked","inputs","reweighted","to","preserve","mean","."]
code: def __call__(
      self,
      inputs,
      deterministic: Optional[bool] = None,
      rng: Optional[KeyArray] = None,
  ):
      """Applies a random dropout mask to the input.
  
      Args:
        inputs: the inputs that should be randomly masked.
        deterministic: if false the inputs are scaled by ``1 / (1 - rate)`` and
          masked, whereas if true, no mask is applied and the inputs are returned
          as is.
        rng: an optional PRNGKey used as the random key, if not specified, one
          will be generated using ``make_rng`` with the ``rng_collection`` name.
  
      Returns:
        The masked inputs reweighted to preserve mean.
      """
      deterministic = merge_param(
          "deterministic", self.deterministic, deterministic
      )
  
      if (self.rate == 0.0) or deterministic:
          return inputs
  
      # Prevent gradient NaNs in 1.0 edge-case.
      if self.rate == 1.0:
          return jnp.zeros_like(inputs)
  
      keep_prob = 1.0 - self.rate
      if rng is None:
          rng = self.make_rng(self.rng_collection)
      broadcast_shape = list(inputs.shape)
      for dim in self.broadcast_dims:
          broadcast_shape[dim] = 1
      mask = random.bernoulli(rng, p=keep_prob, shape=broadcast_shape)
      mask = jnp.broadcast_to(mask, inputs.shape)
      return lax.select(
          mask, inputs / keep_prob, jnp.zeros_like(inputs)
      )
  
imports: from typing import Optional, Sequence
  import jax
  import jax.numpy
  from jax import lax, random
  from flax.linen.module import Module, compact, merge_param
label_desc: Use image node_id 1 for calling the Dropout obj's underlying member method code with example usage: obj.__call__(inputs, deterministic, rng) and returns: lax, inputs, jnp