class_docstr: This class defines the `MobileViT block <https://arxiv.org/abs/2110.02178?context=cs.LG>`_
  
  Args:
      opts: command line arguments
      in_channels (int): :math:`C_{in}` from an expected input of size :math:`(N, C_{in}, H, W)`
      transformer_dim (int): Input dimension to the transformer unit
      ffn_dim (int): Dimension of the FFN block
      n_transformer_blocks (Optional[int]): Number of transformer blocks. Default: 2
      head_dim (Optional[int]): Head dimension in the multi-head attention. Default: 32
      attn_dropout (Optional[float]): Dropout in multi-head attention. Default: 0.0
      dropout (Optional[float]): Dropout rate. Default: 0.0
      ffn_dropout (Optional[float]): Dropout between FFN layers in transformer. Default: 0.0
      patch_h (Optional[int]): Patch height for unfolding operation. Default: 8
      patch_w (Optional[int]): Patch width for unfolding operation. Default: 8
      transformer_norm_layer (Optional[str]): Normalization layer in the transformer block. Default: layer_norm
      conv_ksize (Optional[int]): Kernel size to learn local representations in MobileViT block. Default: 3
      dilation (Optional[int]): Dilation rate in convolutions. Default: 1
      no_fusion (Optional[bool]): Do not combine the input and output feature maps. Default: False
code: def __init__(
      self,
      opts,
      in_channels: int,
      transformer_dim: int,
      ffn_dim: int,
      n_transformer_blocks: Optional[int] = 2,
      head_dim: Optional[int] = 32,
      attn_dropout: Optional[float] = 0.0,
      dropout: Optional[int] = 0.0,
      ffn_dropout: Optional[int] = 0.0,
      patch_h: Optional[int] = 8,
      patch_w: Optional[int] = 8,
      transformer_norm_layer: Optional[str] = "layer_norm",
      conv_ksize: Optional[int] = 3,
      dilation: Optional[int] = 1,
      no_fusion: Optional[bool] = False,
      *args,
      **kwargs,
  ) -> None:
      conv_3x3_in = ConvLayer2d(
          opts=opts,
          in_channels=in_channels,
          out_channels=in_channels,
          kernel_size=conv_ksize,
          stride=1,
          use_norm=True,
          use_act=True,
          dilation=dilation,
      )
      conv_1x1_in = ConvLayer2d(
          opts=opts,
          in_channels=in_channels,
          out_channels=transformer_dim,
          kernel_size=1,
          stride=1,
          use_norm=False,
          use_act=False,
      )
  
      conv_1x1_out = ConvLayer2d(
          opts=opts,
          in_channels=transformer_dim,
          out_channels=in_channels,
          kernel_size=1,
          stride=1,
          use_norm=True,
          use_act=True,
      )
      conv_3x3_out = None
      if not no_fusion:
          conv_3x3_out = ConvLayer2d(
              opts=opts,
              in_channels=2 * in_channels,
              out_channels=in_channels,
              kernel_size=conv_ksize,
              stride=1,
              use_norm=True,
              use_act=True,
          )
      super().__init__()
      self.local_rep = nn.Sequential()
      self.local_rep.add_module(name="conv_3x3", module=conv_3x3_in)
      self.local_rep.add_module(name="conv_1x1", module=conv_1x1_in)
  
      assert transformer_dim % head_dim == 0
      num_heads = transformer_dim // head_dim
  
      global_rep = [
          TransformerEncoder(
              opts=opts,
              embed_dim=transformer_dim,
              ffn_latent_dim=ffn_dim,
              num_heads=num_heads,
              attn_dropout=attn_dropout,
              dropout=dropout,
              ffn_dropout=ffn_dropout,
              transformer_norm_layer=transformer_norm_layer,
          )
          for _ in range(n_transformer_blocks)
      ]
      global_rep.append(
          get_normalization_layer(
              opts=opts,
              norm_type=transformer_norm_layer,
              num_features=transformer_dim,
          )
      )
      self.global_rep = nn.Sequential(*global_rep)
  
      self.conv_proj = conv_1x1_out
  
      self.fusion = conv_3x3_out
  
      self.patch_h = patch_h
      self.patch_w = patch_w
      self.patch_area = self.patch_w * self.patch_h
  
      self.cnn_in_dim = in_channels
      self.cnn_out_dim = transformer_dim
      self.n_heads = num_heads
      self.ffn_dim = ffn_dim
      self.dropout = dropout
      self.attn_dropout = attn_dropout
      self.ffn_dropout = ffn_dropout
      self.dilation = dilation
      self.n_blocks = n_transformer_blocks
      self.conv_ksize = conv_ksize
  
imports: import math
  from typing import Dict, Optional, Sequence, Tuple, Union
  import numpy
  import torch
  from torch import Tensor, nn
  from torch.nn import functional
  from cvnets.layers import ConvLayer2d, get_normalization_layer
  from cvnets.modules.base_module import BaseModule
  from cvnets.modules.transformer import LinearAttnFFN, TransformerEncoder
label_desc: Use image node_id 1 to create a new MobileViTBlock object from inherited base classes: BaseModule with example: obj = MobileViTBlock(opts, in_channels, transformer_dim, ffn_dim, n_transformer_blocks, head_dim, attn_dropout, dropout, ffn_dropout, patch_h, patch_w, transformer_norm_layer, conv_ksize, dilation, no_fusion)