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 (int): Number of transformer blocks. Default: 2
      head_dim (int): Head dimension in the multi-head attention. Default: 32
      attn_dropout (float): Dropout in multi-head attention. Default: 0.0
      dropout (float): Dropout rate. Default: 0.0
      ffn_dropout (float): Dropout between FFN layers in transformer. Default: 0.0
      patch_h (int): Patch height for unfolding operation. Default: 8
      patch_w (int): Patch width for unfolding operation. Default: 8
      transformer_norm_layer (Optional[str]): Normalization layer in the transformer block. Default: layer_norm
      conv_ksize (int): Kernel size to learn local representations in MobileViT block. Default: 3
      no_fusion (Optional[bool]): Do not combine the input and output feature maps. Default: False
class_docstr_tok: ["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","(","int",")",":","Number","of","transformer","blocks",".","Default",":","2","head_dim","(","int",")",":","Head","dimension","in","the","multi-head","attention",".","Default",":","32","attn_dropout","(","float",")",":","Dropout","in","multi-head","attention",".","Default",":","0.0","dropout","(","float",")",":","Dropout","rate",".","Default",":","0.0","ffn_dropout","(","float",")",":","Dropout","between","FFN","layers","in","transformer",".","Default",":","0.0","patch_h","(","int",")",":","Patch","height","for","unfolding","operation",".","Default",":","8","patch_w","(","int",")",":","Patch","width","for","unfolding","operation",".","Default",":","8","transformer_norm_layer","(","Optional","[","str","]",")",":","Normalization","layer","in","the","transformer","block",".","Default",":","layer_norm","conv_ksize","(","int",")",":","Kernel","size","to","learn","local","representations","in","MobileViT","block",".","Default",":","3","no_fusion","(","Optional","[","bool","]",")",":","Do","not","combine","the","input","and","output","feature","maps",".","Default",":","False"]
code: def __init__(
      self,
      in_channels: int,
      transformer_dim: int,
      ffn_dim: int,
      n_transformer_blocks: int = 2,
      head_dim: int = 32,
      attn_dropout: float = 0.0,
      dropout: float = 0.0,
      ffn_dropout: float = 0.0,
      patch_h: int = 8,
      patch_w: int = 8,
      conv_ksize: Optional[int] = 3,
      *args,
      **kwargs,
  ) -> None:
      super().__init__()
  
      conv_3x3_in = ConvLayer(
          in_channels=in_channels,
          out_channels=in_channels,
          kernel_size=conv_ksize,
          stride=1,
      )
      conv_1x1_in = ConvLayer(
          in_channels=in_channels,
          out_channels=transformer_dim,
          kernel_size=1,
          stride=1,
          use_norm=False,
          use_act=False,
      )
  
      conv_1x1_out = ConvLayer(
          in_channels=transformer_dim,
          out_channels=in_channels,
          kernel_size=1,
          stride=1,
      )
      conv_3x3_out = ConvLayer(
          in_channels=2 * in_channels,
          out_channels=in_channels,
          kernel_size=conv_ksize,
          stride=1,
      )
  
      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(
              embed_dim=transformer_dim,
              ffn_latent_dim=ffn_dim,
              num_heads=num_heads,
              attn_dropout=attn_dropout,
              dropout=dropout,
              ffn_dropout=ffn_dropout,
          )
          for _ in range(n_transformer_blocks)
      ]
      global_rep.append(nn.LayerNorm(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.n_blocks = n_transformer_blocks
      self.conv_ksize = conv_ksize
  
imports: from typing import Optional, Tuple, Union, Dict
  import math
  import torch
  import torch.nn
  from torch import Tensor
  from torch.nn import functional
  from transformer import TransformerEncoder
  from model_config import get_config
label_desc: Use image node_id 1 to create a new MobileViTBlock object from inherited base classes: nn with example: obj = MobileViTBlock(in_channels, transformer_dim, ffn_dim, n_transformer_blocks, head_dim, attn_dropout, dropout, ffn_dropout, patch_h, patch_w, conv_ksize)