class_docstr: MLP as used in Vision Transformer, MLP-Mixer and related networks
      
docstr: TD [2021-10-27] act_fn takes precedence over act_layer if set.
  This is to support Pytorch 1.10 Transformer interface that construct the activation
  *function*, not the activation *layer*.
docstr_tok: ["TD","[","2021-10-27","]","act_fn","takes","precedence","over","act_layer","if","set",".","This","is","to","support","Pytorch","1.10","Transformer","interface","that","construct","the","activation","*","function","*",",","not","the","activation","*","layer","*","."]
code: def __init__(
      self,
      in_features,
      hidden_features=None,
      out_features=None,
      act_layer=nn.GELU,
      act_fn=None,
      drop=0.0,
      device=None,
      dtype=None,
  ):
      """TD [2021-10-27] act_fn takes precedence over act_layer if set.
      This is to support Pytorch 1.10 Transformer interface that construct the activation
      *function*, not the activation *layer*.
      """
      factory_kwargs = {"device": device, "dtype": dtype}
      super().__init__()
      out_features = out_features or in_features
      hidden_features = hidden_features or in_features
      drop_probs = _pair(drop)
      self.fc1 = nn.Linear(
          in_features, hidden_features, **factory_kwargs
      )
      self.act = act_layer() if act_fn is None else act_fn
      self.drop1 = nn.Dropout(drop_probs[0])
      self.fc2 = nn.Linear(
          hidden_features, out_features, **factory_kwargs
      )
      self.drop2 = nn.Dropout(drop_probs[1])
  
imports: import math
  from functools import partial
  from collections import namedtuple
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.nn.modules.utils import _pair
  import hydra
  from einops import reduce, rearrange
label_desc: Use image node_id 1 to create a new Mlp object from inherited base classes: nn with example: obj = Mlp(in_features, hidden_features, out_features, act_layer, act_fn, drop, device, dtype)