code: def __init__(
      self,
      in_chans=3,
      num_classes=1000,
      global_pool="avg",
      depths=(3, 4, 6, 3),
      embed_dims=(64, 128, 256, 512),
      num_heads=(1, 2, 4, 8),
      sr_ratios=(8, 4, 2, 1),
      mlp_ratios=(8.0, 8.0, 4.0, 4.0),
      qkv_bias=True,
      linear=False,
      drop_rate=0.0,
      proj_drop_rate=0.0,
      attn_drop_rate=0.0,
      drop_path_rate=0.0,
      norm_layer=LayerNorm,
  ):
      super().__init__()
      self.num_classes = num_classes
      assert global_pool in ("avg", "")
      self.global_pool = global_pool
      self.depths = depths
      num_stages = len(depths)
      mlp_ratios = to_ntuple(num_stages)(mlp_ratios)
      num_heads = to_ntuple(num_stages)(num_heads)
      sr_ratios = to_ntuple(num_stages)(sr_ratios)
      assert (len(embed_dims)) == num_stages
      self.feature_info = []
  
      self.patch_embed = OverlapPatchEmbed(
          patch_size=7,
          stride=4,
          in_chans=in_chans,
          embed_dim=embed_dims[0],
      )
  
      dpr = [
          x.tolist()
          for x in torch.linspace(0, drop_path_rate, sum(depths)).split(
              depths
          )
      ]
      cur = 0
      prev_dim = embed_dims[0]
      stages = []
      for i in range(num_stages):
          stages += [
              PyramidVisionTransformerStage(
                  dim=prev_dim,
                  dim_out=embed_dims[i],
                  depth=depths[i],
                  downsample=i > 0,
                  num_heads=num_heads[i],
                  sr_ratio=sr_ratios[i],
                  mlp_ratio=mlp_ratios[i],
                  linear_attn=linear,
                  qkv_bias=qkv_bias,
                  proj_drop=proj_drop_rate,
                  attn_drop=attn_drop_rate,
                  drop_path=dpr[i],
                  norm_layer=norm_layer,
              )
          ]
          prev_dim = embed_dims[i]
          cur += depths[i]
          self.feature_info += [
              dict(
                  num_chs=prev_dim,
                  reduction=4 * 2**i,
                  module=f"stages.{i}",
              )
          ]
      self.stages = nn.Sequential(*stages)
  
      # classification head
      self.num_features = embed_dims[-1]
      self.head_drop = nn.Dropout(drop_rate)
      self.head = (
          nn.Linear(embed_dims[-1], num_classes)
          if num_classes > 0
          else nn.Identity()
      )
  
      self.apply(self._init_weights)
  
imports: import math
  from typing import Tuple, List, Callable, Union
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils.checkpoint
  from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
  from timm.layers import DropPath, to_2tuple, to_ntuple, trunc_normal_, LayerNorm, use_fused_attn
  from ._builder import build_model_with_cfg
  from ._registry import register_model, generate_default_cfgs
label_desc: Use image node_id 1 to create a new PyramidVisionTransformerV2 object from inherited base classes: nn with example: obj = PyramidVisionTransformerV2(in_chans, num_classes, global_pool, depths, embed_dims, num_heads, sr_ratios, mlp_ratios, qkv_bias, linear, drop_rate, proj_drop_rate, attn_drop_rate, drop_path_rate, norm_layer)