class_docstr: A multi-layer perceptron module.
class_docstr_tok: ["A","multi-layer","perceptron","module","."]
docstr: Connects the module to some inputs.
  
  Args:
    inputs: A Tensor of shape ``[batch_size, input_size]``.
    dropout_rate: Optional dropout rate.
    rng: Optional RNG key. Require when using dropout.
  
  Returns:
    The output of the model of size ``[batch_size, output_size]``.
docstr_tok: ["Connects","the","module","to","some","inputs",".","Args",":","inputs",":","A","Tensor","of","shape","``","[","batch_size",",","input_size","]","``",".","dropout_rate",":","Optional","dropout","rate",".","rng",":","Optional","RNG","key",".","Require","when","using","dropout",".","Returns",":","The","output","of","the","model","of","size","``","[","batch_size",",","output_size","]","``","."]
code: def __call__(
      self,
      inputs: jax.Array,
      dropout_rate: Optional[float] = None,
      rng=None,
  ) -> jax.Array:
      """Connects the module to some inputs.
  
      Args:
        inputs: A Tensor of shape ``[batch_size, input_size]``.
        dropout_rate: Optional dropout rate.
        rng: Optional RNG key. Require when using dropout.
  
      Returns:
        The output of the model of size ``[batch_size, output_size]``.
      """
      if dropout_rate is not None and rng is None:
          raise ValueError(
              "When using dropout an rng key must be passed."
          )
      elif dropout_rate is None and rng is not None:
          raise ValueError(
              "RNG should only be passed when using dropout."
          )
  
      rng = hk.PRNGSequence(rng) if rng is not None else None
      num_layers = len(self.layers)
  
      out = inputs
      for i, layer in enumerate(self.layers):
          out = layer(out)
          if i < (num_layers - 1) or self.activate_final:
              # Only perform dropout if we are activating the output.
              if dropout_rate is not None:
                  out = hk.dropout(next(rng), dropout_rate, out)
              out = self.activation(out)
  
      return out
  
file_path: dm-haiku/haiku/_src/nets/mlp.py
imports: from collections.abc import Iterable
  from typing import Callable, Optional
  from haiku._src import base
  from haiku._src import basic
  from haiku._src import initializers
  from haiku._src import module
  import jax
label_desc: Use image node_id 2 for calling the MLP obj's underlying member method code with example usage: obj.__call__(inputs, dropout_rate, rng) and returns: out