class_docstr: The Inverted Residual Block, with channel shuffle or eSEModule.
class_docstr_tok: ["The","Inverted","Residual","Block",",","with","channel","shuffle","or","eSEModule","."]
code: def __init__(
      self,
      in_ch,
      out_ch,
      stride=1,
      kernel=3,
      expand=1,
      res=False,
      dilation=1,
      se=False,
      fm_size=7,
      group=1,
      mid_ch=-1,
  ):
      super(MBBlock, self).__init__()
      assert stride in [1, 2], "stride should be in [1, 2]"
      assert kernel in [3, 5], "kernel size should be in [3, 5]"
      assert dilation in [
          1,
          2,
          3,
          4,
      ], "dilation should be in [1, 2, 3, 4]"
      assert group in [1, 2], "group should be in [1, 2]"
  
      self.use_res_connect = res and (stride == 1)
      padding = kernel // 2 + (dilation - 1)
      mid_ch = mid_ch if mid_ch > 0 else (in_ch * expand)
  
      # Basic Modules
      conv_layer = nn.Conv2d
      norm_layer = nn.BatchNorm2d
      activation_layer = nn.ReLU
      channel_suffle = ChannelShuffle
      se_layer = eSEModule
  
      self.ir_block = nn.Sequential(
          # pointwise convolution
          conv_layer(in_ch, mid_ch, 1, 1, 0, bias=False, groups=group),
          norm_layer(mid_ch),
          activation_layer(inplace=True),
          # channel shuffle if necessary
          channel_suffle(group),
          # depthwise convolution
          conv_layer(
              mid_ch,
              mid_ch,
              kernel,
              stride,
              padding=padding,
              dilation=dilation,
              groups=mid_ch,
              bias=False,
          ),
          norm_layer(mid_ch),
          # eSEModule if necessary
          se_layer(mid_ch, fm_size, se),
          activation_layer(inplace=True),
          # pointwise convolution
          conv_layer(mid_ch, out_ch, 1, 1, 0, bias=False, groups=group),
          norm_layer(out_ch),
      )
  
imports: from __future__ import absolute_import, division, print_function
  import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 1 to create a new MBBlock object from inherited base classes: nn with example: obj = MBBlock(in_ch, out_ch, stride, kernel, expand, res, dilation, se, fm_size, group, mid_ch)