code: def __init__(self, inp: int, oup: int, stride: int) -> None:
      super().__init__()
  
      if not (1 <= stride <= 3):
          raise ValueError("illegal stride value")
      self.stride = stride
  
      branch_features = oup // 2
      if (self.stride == 1) and (inp != branch_features << 1):
          raise ValueError(
              f"Invalid combination of stride {stride}, inp {inp} and oup {oup} values. If stride == 1 then inp should be equal to oup // 2 << 1."
          )
  
      if self.stride > 1:
          self.branch1 = nn.Sequential(
              self.depthwise_conv(
                  inp, inp, kernel_size=3, stride=self.stride, padding=1
              ),
              nn.BatchNorm2d(inp),
              nn.Conv2d(
                  inp,
                  branch_features,
                  kernel_size=1,
                  stride=1,
                  padding=0,
                  bias=False,
              ),
              nn.BatchNorm2d(branch_features),
              nn.ReLU(inplace=True),
          )
      else:
          self.branch1 = nn.Sequential()
  
      self.branch2 = nn.Sequential(
          nn.Conv2d(
              inp if (self.stride > 1) else branch_features,
              branch_features,
              kernel_size=1,
              stride=1,
              padding=0,
              bias=False,
          ),
          nn.BatchNorm2d(branch_features),
          nn.ReLU(inplace=True),
          self.depthwise_conv(
              branch_features,
              branch_features,
              kernel_size=3,
              stride=self.stride,
              padding=1,
          ),
          nn.BatchNorm2d(branch_features),
          nn.Conv2d(
              branch_features,
              branch_features,
              kernel_size=1,
              stride=1,
              padding=0,
              bias=False,
          ),
          nn.BatchNorm2d(branch_features),
          nn.ReLU(inplace=True),
      )
  
imports: from functools import partial
  from typing import Any, Callable, List, Optional
  import torch
  import torch.nn
  from torch import Tensor
  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 _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)