class_docstr: This layer is introduced in section 4.2 in the paper https://arxiv.org/pdf/1812.00332.pdf
class_docstr_tok: ["This","layer","is","introduced","in","section","4.2","in","the","paper","https",":","\/\/arxiv.org\/pdf\/1812.00332.pdf"]
code: def __init__(
      self,
      in_channels,
      out_channels,
      kernel_size=3,
      stride=1,
      expand_ratio=6,
      mid_channels=None,
  ):
      super(MBInvertedConvLayer, self).__init__()
  
      self.in_channels = in_channels
      self.out_channels = out_channels
  
      self.kernel_size = kernel_size
      self.stride = stride
      self.expand_ratio = expand_ratio
      self.mid_channels = mid_channels
  
      if self.mid_channels is None:
          feature_dim = round(self.in_channels * self.expand_ratio)
      else:
          feature_dim = self.mid_channels
  
      if self.expand_ratio == 1:
          self.inverted_bottleneck = nn.Sequential()
      else:
          self.inverted_bottleneck = nn.Sequential(
              OrderedDict(
                  [
                      (
                          "conv",
                          nn.Conv2d(
                              self.in_channels,
                              feature_dim,
                              1,
                              1,
                              0,
                              bias=False,
                          ),
                      ),
                      ("bn", nn.BatchNorm2d(feature_dim)),
                      ("act", nn.ReLU6(inplace=True)),
                  ]
              )
          )
  
      pad = get_same_padding(self.kernel_size)
      self.depth_conv = nn.Sequential(
          OrderedDict(
              [
                  (
                      "conv",
                      nn.Conv2d(
                          feature_dim,
                          feature_dim,
                          kernel_size,
                          stride,
                          pad,
                          groups=feature_dim,
                          bias=False,
                      ),
                  ),
                  ("bn", nn.BatchNorm2d(feature_dim)),
                  ("act", nn.ReLU6(inplace=True)),
              ]
          )
      )
  
      self.point_linear = nn.Sequential(
          OrderedDict(
              [
                  (
                      "conv",
                      nn.Conv2d(
                          feature_dim, out_channels, 1, 1, 0, bias=False
                      ),
                  ),
                  ("bn", nn.BatchNorm2d(out_channels)),
              ]
          )
      )
  
imports: from collections import OrderedDict
  from nni.retiarii.serializer import basic_unit
  import torch
  import nni.retiarii.nn.pytorch
  from putils import get_same_padding, build_activation
label_desc: Use image node_id 1 to create a new MBInvertedConvLayer object from inherited base classes: nn with example: obj = MBInvertedConvLayer(in_channels, out_channels, kernel_size, stride, expand_ratio, mid_channels)