class_docstr: This class defines the `MobileViTv2 <https://arxiv.org/abs/2206.02680>`_ block
  
  Args:
      opts: command line arguments
      in_channels (int): :math:`C_{in}` from an expected input of size :math:`(N, C_{in}, H, W)`
      attn_unit_dim (int): Input dimension to the attention unit
      ffn_multiplier (int): Expand the input dimensions by this factor in FFN. Default is 2.
      n_attn_blocks (Optional[int]): Number of attention units. Default: 2
      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
      conv_ksize (Optional[int]): Kernel size to learn local representations in MobileViT block. Default: 3
      dilation (Optional[int]): Dilation rate in convolutions. Default: 1
      attn_norm_layer (Optional[str]): Normalization layer in the attention block. Default: layer_norm_2d
code: def forward_spatial(self, x: Tensor, *args, **kwargs) -> Tensor:
      x = self.resize_input_if_needed(x)
  
      fm = self.local_rep(x)
  
      # convert feature map to patches
      if self.enable_coreml_compatible_fn:
          patches, output_size = self.unfolding_coreml(fm)
      else:
          patches, output_size = self.unfolding_pytorch(fm)
  
      # learn global representations on all patches
      patches = self.global_rep(patches)
  
      # [B x Patch x Patches x C] --> [B x C x Patches x Patch]
      if self.enable_coreml_compatible_fn:
          fm = self.folding_coreml(
              patches=patches, output_size=output_size
          )
      else:
          fm = self.folding_pytorch(
              patches=patches, output_size=output_size
          )
      fm = self.conv_proj(fm)
  
      return fm
  
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 10 for calling the MobileViTBlockv2 obj's underlying member method code with example usage: obj.forward_spatial(x) and returns: fm