class_docstr: ## MLP Mixer
  
  This module is a drop-in replacement for [self-attention layer](../mha.html).
  It transposes the input tensor before feeding it to the MLP and transposes back,
  so that the MLP is applied across the sequence dimension (across tokens or image patches) instead
  of the feature dimension.
class_docstr_tok: ["#","#","MLP","Mixer","This","module","is","a","drop-in","replacement","for","[","self-attention","layer","]","(","..","\/mha.html",")",".","It","transposes","the","input","tensor","before","feeding","it","to","the","MLP","and","transposes","back",",","so","that","the","MLP","is","applied","across","the","sequence","dimension","(","across","tokens","or","image","patches",")","instead","of","the","feature","dimension","."]
docstr: * `ffn` is the MLP module.
docstr_tok: ["*","`","ffn","`","is","the","MLP","module","."]
code: def __init__(self, mlp: nn.Module):
      """
      * `ffn` is the MLP module.
      """
      super().__init__()
      self.mlp = mlp
  
imports: from typing import Optional
  import torch
  from torch import nn
label_desc: Use image node_id 1 to create a new MLPMixer object from inherited base classes: nn with example: obj = MLPMixer(mlp)