code: def __init__(
      self,
      inp: int,
      oup: int,
      stride: int,
      expand_ratio: int,
      norm_layer: Optional[Callable[..., nn.Module]] = None,
  ) -> None:
      super().__init__()
      self.stride = stride
      if stride not in [1, 2]:
          raise ValueError(
              f"stride should be 1 or 2 instead of {stride}"
          )
  
      if norm_layer is None:
          norm_layer = nn.BatchNorm2d
  
      hidden_dim = int(round(inp * expand_ratio))
      self.use_res_connect = self.stride == 1 and inp == oup
  
      layers: List[nn.Module] = []
      if expand_ratio != 1:
          # pw
          layers.append(
              Conv2dNormActivation(
                  inp,
                  hidden_dim,
                  kernel_size=1,
                  norm_layer=norm_layer,
                  activation_layer=nn.ReLU6,
              )
          )
      layers.extend(
          [
              # dw
              Conv2dNormActivation(
                  hidden_dim,
                  hidden_dim,
                  stride=stride,
                  groups=hidden_dim,
                  norm_layer=norm_layer,
                  activation_layer=nn.ReLU6,
              ),
              # pw-linear
              nn.Conv2d(hidden_dim, oup, 1, 1, 0, bias=False),
              norm_layer(oup),
          ]
      )
      self.conv = nn.Sequential(*layers)
      self.out_channels = oup
      self._is_cn = stride > 1
  
imports: from functools import partial
  from typing import Any, Callable, List, Optional
  import torch
  from torch import nn, Tensor
  from ..ops.misc import Conv2dNormActivation
  from ..transforms._presets import ImageClassification
  from ..utils import _log_api_usage_once
  from ._api import register_model, Weights, WeightsEnum
  from ._meta import _IMAGENET_CATEGORIES
  from ._utils import _make_divisible, _ovewrite_named_param, handle_legacy_interface
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, norm_layer)