class_docstr: Inverted residual block w/ optional SE
  
  Originally used in MobileNet-V2 - https://arxiv.org/abs/1801.04381v4, this layer is often
  referred to as 'MBConv' for (Mobile inverted bottleneck conv) and is also used in
    * MNasNet - https://arxiv.org/abs/1807.11626
    * EfficientNet - https://arxiv.org/abs/1905.11946
    * MobileNet-V3 - https://arxiv.org/abs/1905.02244
class_docstr_tok: ["Inverted","residual","block","w\/","optional","SE","Originally","used","in","MobileNet-V2","-","https",":","\/\/arxiv.org\/abs\/1801.04381v4",",","this","layer","is","often","referred","to","as","'MBConv","'","for","(","Mobile","inverted","bottleneck","conv",")","and","is","also","used","in","*","MNasNet","-","https",":","\/\/arxiv.org\/abs\/1807.11626","*","EfficientNet","-","https",":","\/\/arxiv.org\/abs\/1905.11946","*","MobileNet-V3","-","https",":","\/\/arxiv.org\/abs\/1905.02244"]
code: def __init__(
      self,
      in_chs,
      out_chs,
      dw_kernel_size=3,
      stride=1,
      dilation=1,
      group_size=1,
      pad_type="",
      noskip=False,
      exp_ratio=1.0,
      exp_kernel_size=1,
      pw_kernel_size=1,
      act_layer=nn.ReLU,
      norm_layer=nn.BatchNorm2d,
      se_layer=None,
      conv_kwargs=None,
      drop_path_rate=0.0,
  ):
      super(InvertedResidual, self).__init__()
      norm_act_layer = get_norm_act_layer(norm_layer, act_layer)
      conv_kwargs = conv_kwargs or {}
      mid_chs = make_divisible(in_chs * exp_ratio)
      groups = num_groups(group_size, mid_chs)
      self.has_skip = (in_chs == out_chs and stride == 1) and not noskip
  
      # Point-wise expansion
      self.conv_pw = create_conv2d(
          in_chs,
          mid_chs,
          exp_kernel_size,
          padding=pad_type,
          **conv_kwargs,
      )
      self.bn1 = norm_act_layer(mid_chs, inplace=True)
  
      # Depth-wise convolution
      self.conv_dw = create_conv2d(
          mid_chs,
          mid_chs,
          dw_kernel_size,
          stride=stride,
          dilation=dilation,
          groups=groups,
          padding=pad_type,
          **conv_kwargs,
      )
      self.bn2 = norm_act_layer(mid_chs, inplace=True)
  
      # Squeeze-and-excitation
      self.se = (
          se_layer(mid_chs, act_layer=act_layer)
          if se_layer
          else nn.Identity()
      )
  
      # Point-wise linear projection
      self.conv_pwl = create_conv2d(
          mid_chs,
          out_chs,
          pw_kernel_size,
          padding=pad_type,
          **conv_kwargs,
      )
      self.bn3 = norm_act_layer(out_chs, apply_act=False)
      self.drop_path = (
          DropPath(drop_path_rate) if drop_path_rate else nn.Identity()
      )
  
imports: import torch
  import torch.nn
  from torch.nn import functional
  from timm.layers import create_conv2d, DropPath, make_divisible, create_act_layer, get_norm_act_layer
label_desc: Use image node_id 1 to create a new InvertedResidual object from inherited base classes: nn with example: obj = InvertedResidual(in_chs, out_chs, dw_kernel_size, stride, dilation, group_size, pad_type, noskip, exp_ratio, exp_kernel_size, pw_kernel_size, act_layer, norm_layer, se_layer, conv_kwargs, drop_path_rate)