class_docstr: Mobile Inverted Residual Bottleneck Block.
  
  Args:
      block_args (namedtuple): BlockArgs, defined in utils.py.
      global_params (namedtuple): GlobalParam, defined in utils.py.
      image_size (tuple or list): [image_height, image_width].
  
  References:
      [1] https://arxiv.org/abs/1704.04861 (MobileNet v1)
      [2] https://arxiv.org/abs/1801.04381 (MobileNet v2)
      [3] https://arxiv.org/abs/1905.02244 (MobileNet v3)
class_docstr_tok: ["Mobile","Inverted","Residual","Bottleneck","Block",".","Args",":","block_args","(","namedtuple",")",":","BlockArgs",",","defined","in","utils.py",".","global_params","(","namedtuple",")",":","GlobalParam",",","defined","in","utils.py",".","image_size","(","tuple","or","list",")",":","[","image_height",",","image_width","]",".","References",":","[","1","]","https",":","\/\/arxiv.org\/abs\/1704.04861","(","MobileNet","v1",")","[","2","]","https",":","\/\/arxiv.org\/abs\/1801.04381","(","MobileNet","v2",")","[","3","]","https",":","\/\/arxiv.org\/abs\/1905.02244","(","MobileNet","v3",")"]
code: def __init__(self, block_args, global_params, image_size=None):
      super().__init__()
      self._block_args = block_args
      self._bn_mom = (
          1 - global_params.batch_norm_momentum
      )  # pytorch's difference from tensorflow
      self._bn_eps = global_params.batch_norm_epsilon
      self.has_se = (self._block_args.se_ratio is not None) and (
          0 < self._block_args.se_ratio <= 1
      )
      self.id_skip = (
          block_args.id_skip
      )  # whether to use skip connection and drop connect
  
      # Expansion phase (Inverted Bottleneck)
      inp = self._block_args.input_filters  # number of input channels
      oup = (
          self._block_args.input_filters * self._block_args.expand_ratio
      )  # number of output channels
      if self._block_args.expand_ratio != 1:
          Conv2d = get_same_padding_conv2d(image_size=image_size)
          self._expand_conv = Conv2d(
              in_channels=inp,
              out_channels=oup,
              kernel_size=1,
              bias=False,
          )
          self._bn0 = nn.BatchNorm2d(
              num_features=oup, momentum=self._bn_mom, eps=self._bn_eps
          )
          # image_size = calculate_output_image_size(image_size, 1) <-- this wouldn't modify image_size
  
      # Depthwise convolution phase
      k = self._block_args.kernel_size
      s = self._block_args.stride
      Conv2d = get_same_padding_conv2d(image_size=image_size)
      self._depthwise_conv = Conv2d(
          in_channels=oup,
          out_channels=oup,
          groups=oup,  # groups makes it depthwise
          kernel_size=k,
          stride=s,
          bias=False,
      )
      self._bn1 = nn.BatchNorm2d(
          num_features=oup, momentum=self._bn_mom, eps=self._bn_eps
      )
      image_size = calculate_output_image_size(image_size, s)
  
      # Squeeze and Excitation layer, if desired
      if self.has_se:
          Conv2d = get_same_padding_conv2d(image_size=(1, 1))
          num_squeezed_channels = max(
              1,
              int(
                  self._block_args.input_filters
                  * self._block_args.se_ratio
              ),
          )
          self._se_reduce = Conv2d(
              in_channels=oup,
              out_channels=num_squeezed_channels,
              kernel_size=1,
          )
          self._se_expand = Conv2d(
              in_channels=num_squeezed_channels,
              out_channels=oup,
              kernel_size=1,
          )
  
      # Pointwise convolution phase
      final_oup = self._block_args.output_filters
      Conv2d = get_same_padding_conv2d(image_size=image_size)
      self._project_conv = Conv2d(
          in_channels=oup,
          out_channels=final_oup,
          kernel_size=1,
          bias=False,
      )
      self._bn2 = nn.BatchNorm2d(
          num_features=final_oup,
          momentum=self._bn_mom,
          eps=self._bn_eps,
      )
      self._swish = MemoryEfficientSwish()
  
imports: import torch
  from torch import nn
  from torch.nn import functional
  from .utils import round_filters, round_repeats, drop_connect, get_same_padding_conv2d, get_model_params, efficientnet_params, load_pretrained_weights, Swish, MemoryEfficientSwish, calculate_output_image_size
label_desc: Use image node_id 1 to create a new MBConvBlock object from inherited base classes: nn with example: obj = MBConvBlock(block_args, global_params, image_size)