class_docstr: Pooling-based Vision Transformer
  
  A PyTorch implement of 'Rethinking Spatial Dimensions of Vision Transformers'
      - https://arxiv.org/abs/2103.16302
class_docstr_tok: ["Pooling-based","Vision","Transformer","A","PyTorch","implement","of","'Rethinking","Spatial","Dimensions","of","Vision","Transformers'","-","https",":","\/\/arxiv.org\/abs\/2103.16302"]
code: def __init__(
      self,
      img_size: int = 224,
      patch_size: int = 16,
      stride: int = 8,
      stem_type: str = "overlap",
      base_dims: Sequence[int] = (48, 48, 48),
      depth: Sequence[int] = (2, 6, 4),
      heads: Sequence[int] = (2, 4, 8),
      mlp_ratio: float = 4,
      num_classes=1000,
      in_chans=3,
      global_pool="token",
      distilled=False,
      drop_rate=0.0,
      pos_drop_drate=0.0,
      proj_drop_rate=0.0,
      attn_drop_rate=0.0,
      drop_path_rate=0.0,
  ):
      super(PoolingVisionTransformer, self).__init__()
      assert global_pool in ("token",)
  
      self.base_dims = base_dims
      self.heads = heads
      embed_dim = base_dims[0] * heads[0]
      self.num_classes = num_classes
      self.global_pool = global_pool
      self.num_tokens = 2 if distilled else 1
      self.feature_info = []
  
      self.patch_embed = ConvEmbedding(
          in_chans, embed_dim, img_size, patch_size, stride
      )
      self.pos_embed = nn.Parameter(
          torch.randn(
              1,
              embed_dim,
              self.patch_embed.height,
              self.patch_embed.width,
          )
      )
      self.cls_token = nn.Parameter(
          torch.randn(1, self.num_tokens, embed_dim)
      )
      self.pos_drop = nn.Dropout(p=pos_drop_drate)
  
      transformers = []
      # stochastic depth decay rule
      dpr = [
          x.tolist()
          for x in torch.linspace(0, drop_path_rate, sum(depth)).split(
              depth
          )
      ]
      prev_dim = embed_dim
      for i in range(len(depth)):
          pool = None
          embed_dim = base_dims[i] * heads[i]
          if i > 0:
              pool = Pooling(
                  prev_dim,
                  embed_dim,
                  stride=2,
              )
          transformers += [
              Transformer(
                  base_dims[i],
                  depth[i],
                  heads[i],
                  mlp_ratio,
                  pool=pool,
                  proj_drop=proj_drop_rate,
                  attn_drop=attn_drop_rate,
                  drop_path_prob=dpr[i],
              )
          ]
          prev_dim = embed_dim
          self.feature_info += [
              dict(
                  num_chs=prev_dim,
                  reduction=(stride - 1) * 2**i,
                  module=f"transformers.{i}",
              )
          ]
  
      self.transformers = SequentialTuple(*transformers)
      self.norm = nn.LayerNorm(base_dims[-1] * heads[-1], eps=1e-6)
      self.num_features = self.embed_dim = embed_dim
  
      # Classifier head
      self.head_drop = nn.Dropout(drop_rate)
      self.head = (
          nn.Linear(self.embed_dim, num_classes)
          if num_classes > 0
          else nn.Identity()
      )
      self.head_dist = None
      if distilled:
          self.head_dist = (
              nn.Linear(self.embed_dim, self.num_classes)
              if num_classes > 0
              else nn.Identity()
          )
      self.distilled_training = (
          False  # must set this True to train w/ distillation token
      )
  
      trunc_normal_(self.pos_embed, std=0.02)
      trunc_normal_(self.cls_token, std=0.02)
      self.apply(self._init_weights)
  
imports: import math
  import re
  from functools import partial
  from typing import Sequence, Tuple
  import torch
  from torch import nn
  from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
  from timm.layers import trunc_normal_, to_2tuple, LayerNorm
  from ._builder import build_model_with_cfg
  from ._registry import register_model, generate_default_cfgs
  from .vision_transformer import Block
label_desc: Use image node_id 1 to create a new PoolingVisionTransformer object from inherited base classes: nn with example: obj = PoolingVisionTransformer(img_size, patch_size, stride, stem_type, base_dims, depth, heads, mlp_ratio, num_classes, in_chans, global_pool, distilled, drop_rate, pos_drop_drate, proj_drop_rate, attn_drop_rate, drop_path_rate)