code: def __init__(self, inp, oup, stride, expand_ratio, activation):
      super(InvertedResidual, self).__init__()
      self.stride = stride
      assert stride in [1, 2]
  
      hidden_dim = round(inp * expand_ratio)
      self.use_res_connect = self.stride == 1 and inp == oup
  
      if expand_ratio == 1:
          self.conv = nn.Sequential(
              # dw
              nn.Conv2d(
                  hidden_dim,
                  hidden_dim,
                  3,
                  stride,
                  1,
                  groups=hidden_dim,
                  bias=False,
              ),
              nn.BatchNorm2d(hidden_dim),
              activation(),
              # pw-linear
              nn.Conv2d(hidden_dim, oup, 1, 1, 0, bias=False),
              nn.BatchNorm2d(oup),
          )
      else:
          self.conv = nn.Sequential(
              # pw
              nn.Conv2d(inp, hidden_dim, 1, 1, 0, bias=False),
              nn.BatchNorm2d(hidden_dim),
              activation(),
              # dw
              nn.Conv2d(
                  hidden_dim,
                  hidden_dim,
                  3,
                  stride,
                  1,
                  groups=hidden_dim,
                  bias=False,
              ),
              nn.BatchNorm2d(hidden_dim),
              activation(),
              # pw-linear
              nn.Conv2d(hidden_dim, oup, 1, 1, 0, bias=False),
              nn.BatchNorm2d(oup),
          )
  
file_path: pytorch-toolbelt/pytorch_toolbelt/modules/backbone/mobilenet.py
imports: from __future__ import absolute_import
  import math
  import torch.nn
  from ..activations import get_activation_block
label_desc: Use image node_id 1 to create a new InvertedResidual object from inherited base classes: nn with example: obj = InvertedResidual(inp, oup, stride, expand_ratio, activation)