class_docstr: MV2 block described in MobileNetV2.
  
  Paper: https://arxiv.org/pdf/1801.04381
  Based on: https://github.com/tonylins/pytorch-mobilenet-v2
  
  Args:
      inp: input channel.
      oup: output channel.
      stride: stride for convolution, defaults to 1, set to 2 if down-sample.
      expansion: expansion ratio for hidden dimension, defaults to 4.
class_docstr_tok: ["MV2","block","described","in","MobileNetV2",".","Paper",":","https",":","\/\/arxiv.org\/pdf\/1801.04381","Based","on",":","https",":","\/\/github.com\/tonylins\/pytorch-mobilenet-v2","Args",":","inp",":","input","channel",".","oup",":","output","channel",".","stride",":","stride","for","convolution",",","defaults","to","1",",","set","to","2","if","down-sample",".","expansion",":","expansion","ratio","for","hidden","dimension",",","defaults","to","4","."]
code: def __init__(
      self, inp: int, oup: int, stride: int = 1, expansion: int = 4
  ) -> None:
      super().__init__()
      self.stride = stride
  
      hidden_dim = int(inp * expansion)
      self.use_res_connect = self.stride == 1 and inp == oup
  
      if expansion == 1:
          self.conv = nn.Sequential(
              # depthwise
              nn.Conv2d(
                  hidden_dim,
                  hidden_dim,
                  3,
                  stride,
                  1,
                  groups=hidden_dim,
                  bias=False,
              ),
              nn.BatchNorm2d(hidden_dim),
              nn.SiLU(),
              # pointwise
              nn.Conv2d(hidden_dim, oup, 1, 1, 0, bias=False),
              nn.BatchNorm2d(oup),
          )
      else:
          self.conv = nn.Sequential(
              # pointwise
              nn.Conv2d(inp, hidden_dim, 1, 1, 0, bias=False),
              nn.BatchNorm2d(hidden_dim),
              nn.SiLU(),
              # depthwise
              nn.Conv2d(
                  hidden_dim,
                  hidden_dim,
                  3,
                  stride,
                  1,
                  groups=hidden_dim,
                  bias=False,
              ),
              nn.BatchNorm2d(hidden_dim),
              nn.SiLU(),
              # pointwise
              nn.Conv2d(hidden_dim, oup, 1, 1, 0, bias=False),
              nn.BatchNorm2d(oup),
          )
  
imports: from typing import Any, Dict, Tuple
  import torch
  from torch import nn
  from kornia.core import Module, Tensor
label_desc: Use image node_id 1 to create a new MV2Block object from inherited base classes: Module with example: obj = MV2Block(inp, oup, stride, expansion)