class_docstr: TinyViT model, as described in https://arxiv.org/abs/2207.10666
  
  Args:
      img_size: Size of input image.
      in_chans: Number of input image's channels.
      num_classes: Number of output classes.
      embed_dims: List of embedding dimensions.
      depths: List of block count for each downsampling stage
      num_heads: List of attention heads used in self-attention for each downsampling stage.
      window_sizes: List of self-attention's window size for each downsampling stage.
      mlp_ratio: Ratio of MLP dimension to embedding dimension in self-attention.
      drop_rate: Dropout rate.
      drop_path_rate: Stochastic depth rate.
      use_checkpoint: Whether to use activation checkpointing to trade compute for memory.
      mbconv_expand_ratio: Expansion ratio used in MBConv block.
      local_conv_size: Kernel size of convolution used in TinyViTBlock
      activation: activation function.
      mobile_same: Whether to use modifications for MobileSAM.
class_docstr_tok: ["TinyViT","model",",","as","described","in","https",":","\/\/arxiv.org\/abs\/2207.10666","Args",":","img_size",":","Size","of","input","image",".","in_chans",":","Number","of","input","image","'s","channels",".","num_classes",":","Number","of","output","classes",".","embed_dims",":","List","of","embedding","dimensions",".","depths",":","List","of","block","count","for","each","downsampling","stage","num_heads",":","List","of","attention","heads","used","in","self-attention","for","each","downsampling","stage",".","window_sizes",":","List","of","self-attention","'s","window","size","for","each","downsampling","stage",".","mlp_ratio",":","Ratio","of","MLP","dimension","to","embedding","dimension","in","self-attention",".","drop_rate",":","Dropout","rate",".","drop_path_rate",":","Stochastic","depth","rate",".","use_checkpoint",":","Whether","to","use","activation","checkpointing","to","trade","compute","for","memory",".","mbconv_expand_ratio",":","Expansion","ratio","used","in","MBConv","block",".","local_conv_size",":","Kernel","size","of","convolution","used","in","TinyViTBlock","activation",":","activation","function",".","mobile_same",":","Whether","to","use","modifications","for","MobileSAM","."]
docstr: Classify images if ``mobile_sam=False``, produce feature maps if ``mobile_sam=True``.
code: def forward(self, x: Tensor) -> Tensor:
      """Classify images if ``mobile_sam=False``, produce feature maps if ``mobile_sam=True``."""
      x = self.patch_embed(x)
      x = self.layers(x)
  
      if self.mobile_sam:
          # MobileSAM
          x = x.unflatten(1, (self.feat_size, self.feat_size)).permute(
              0, 3, 1, 2
          )
          x = self.neck(x)  # type: ignore
      else:
          # classification
          x = x.mean(1)
          x = self.head(self.norm_head(x))
      return x
  
imports: from __future__ import annotations
  import itertools
  import warnings
  from typing import Any, Optional
  import torch
  import torch.nn.functional
  from torch import nn
  from torch.utils import checkpoint
  from kornia.contrib.models.common import DropPath, LayerNorm2d, window_partition, window_unpartition
  from kornia.core import Module, Tensor
  from kornia.core.check import KORNIA_CHECK
label_desc: Use image node_id 2 for calling the TinyViT obj's underlying member method code with example usage: obj.forward(x) and returns: x