def __init__(self, in_channels, out_channels, stride, expand_ratio, dilation=1, conv_cfg=None, norm_cfg=dict(type='BN'), act_cfg=dict(type='ReLU6'), with_cp=False):
    super(InvertedResidual, self).__init__()
    self.stride = stride
    assert (stride in [1, 2]), f'stride must in [1, 2]. But received {stride}.'
    self.with_cp = with_cp
    self.use_res_connect = ((self.stride == 1) and (in_channels == out_channels))
    hidden_dim = int(round((in_channels * expand_ratio)))
    layers = []
    if (expand_ratio != 1):
        layers.append(ConvModule(in_channels=in_channels, out_channels=hidden_dim, kernel_size=1, conv_cfg=conv_cfg, norm_cfg=norm_cfg, act_cfg=act_cfg))
    layers.extend([ConvModule(in_channels=hidden_dim, out_channels=hidden_dim, kernel_size=3, stride=stride, padding=dilation, dilation=dilation, groups=hidden_dim, conv_cfg=conv_cfg, norm_cfg=norm_cfg, act_cfg=act_cfg), ConvModule(in_channels=hidden_dim, out_channels=out_channels, kernel_size=1, conv_cfg=conv_cfg, norm_cfg=norm_cfg, act_cfg=None)])
    self.conv = nn.Sequential(*layers)
def __init__(self, in_channels, out_channels, stride, expand_ratio, dilation=1, conv_cfg=None, norm_cfg=dict(type='BN'), act_cfg=dict(type='ReLU6'), with_cp=False):
    super(InvertedResidual, self).__init__()
    self.stride = stride
    assert (stride in [1, 2]), f'stride must in [1, 2]. But received {stride}.'
    self.with_cp = with_cp
    self.use_res_connect = ((self.stride == 1) and (in_channels == out_channels))
    hidden_dim = int(round((in_channels * expand_ratio)))
    layers = []
    if (expand_ratio != 1):
        layers.append(ConvModule(in_channels=in_channels, out_channels=hidden_dim, kernel_size=1, conv_cfg=conv_cfg, norm_cfg=norm_cfg, act_cfg=act_cfg))
    layers.extend([ConvModule(in_channels=hidden_dim, out_channels=hidden_dim, kernel_size=3, stride=stride, padding=dilation, dilation=dilation, groups=hidden_dim, conv_cfg=conv_cfg, norm_cfg=norm_cfg, act_cfg=act_cfg), ConvModule(in_channels=hidden_dim, out_channels=out_channels, kernel_size=1, conv_cfg=conv_cfg, norm_cfg=norm_cfg, act_cfg=None)])
    self.conv = nn.Sequential(*layers)