class_docstr: Video Swin Transformer.
  Ze Liu, Jia Ning, Yue Cao, Yixuan Wei, Zheng Zhang, Stephen Lin, Han Hu
  https://arxiv.org/pdf/2106.13230.pdf
  
  Args:
      pretrained (`str`):
          Load pretrained weights. Default: None
      pretrained2d (`bool`):
          Load image pretrained weights. Default: False
      patch_size (`tuple[int]`):
          Patch size. Default: (4,4,4).
      in_chans (`int)`:
          Number of input image channels. Default: 3.
      embed_dim (`int`):
          Number of linear projection output channels. Default: 96.
      depths (`tuple[int]`):
          Depths of each Swin Transformer stage.
      num_heads (`tuple[int]`):
          Number of attention head of each stage.
      window_size (`int`):
          Window size. Default: 7.
      mlp_ratio (`float`):
          Ratio of mlp hidden dim to embedding dim. Default: 4.
      num_classes (`int`):
          the classification num.
      qkv_bias (`bool`):
          If True, add a learnable bias to query, key, value. Default: True
      qk_scale (`float`):
          Override default qk scale of head_dim ** -0.5 if set.
      drop_rate (`float`):
          Dropout rate.
      attn_drop_rate (`float`):
          Attention dropout rate. Default: 0.
      drop_path_rate (`float`):
          Stochastic depth rate. Default: 0.2.
      norm_layer (`nn.Module`):
          Normalization layer. Default: nn.LayerNorm.
      patch_norm (`bool`):
          If True, add normalization after patch embedding. Default: False.
      frozen_stages (`int`):
          Stages to be frozen (stop grad and set eval mode).
          -1 means not freezing any parameters.
      use_checkpoint (`bool`):
          Use checkpoint.
      stride (`tuple[int]`):
          stride size for patch embed3d.
class_docstr_tok: ["Video","Swin","Transformer",".","Ze","Liu",",","Jia","Ning",",","Yue","Cao",",","Yixuan","Wei",",","Zheng","Zhang",",","Stephen","Lin",",","Han","Hu","https",":","\/\/arxiv.org\/pdf\/2106.13230.pdf","Args",":","pretrained","(","`","str","`",")",":","Load","pretrained","weights",".","Default",":","None","pretrained2d","(","`","bool","`",")",":","Load","image","pretrained","weights",".","Default",":","False","patch_size","(","`","tuple","[","int","]","`",")",":","Patch","size",".","Default",":","(","4,4,4",")",".","in_chans","(","`","int",")","`",":","Number","of","input","image","channels",".","Default",":","3.","embed_dim","(","`","int","`",")",":","Number","of","linear","projection","output","channels",".","Default",":","96.","depths","(","`","tuple","[","int","]","`",")",":","Depths","of","each","Swin","Transformer","stage",".","num_heads","(","`","tuple","[","int","]","`",")",":","Number","of","attention","head","of","each","stage",".","window_size","(","`","int","`",")",":","Window","size",".","Default",":","7.","mlp_ratio","(","`","float","`",")",":","Ratio","of","mlp","hidden","dim","to","embedding","dim",".","Default",":","4.","num_classes","(","`","int","`",")",":","the","classification","num",".","qkv_bias","(","`","bool","`",")",":","If","True",",","add","a","learnable","bias","to","query",",","key",",","value",".","Default",":","True","qk_scale","(","`","float","`",")",":","Override","default","qk","scale","of","head_dim","*","*","-0.5","if","set",".","drop_rate","(","`","float","`",")",":","Dropout","rate",".","attn_drop_rate","(","`","float","`",")",":","Attention","dropout","rate",".","Default",":","0.","drop_path_rate","(","`","float","`",")",":","Stochastic","depth","rate",".","Default",":","0.2.","norm_layer","(","`","nn.Module","`",")",":","Normalization","layer",".","Default",":","nn.LayerNorm",".","patch_norm","(","`","bool","`",")",":","If","True",",","add","normalization","after","patch","embedding",".","Default",":","False",".","frozen_stages","(","`","int","`",")",":","Stages","to","be","frozen","(","stop","grad","and","set","eval","mode",")",".","-1","means","not","freezing","any","parameters",".","use_checkpoint","(","`","bool","`",")",":","Use","checkpoint",".","stride","(","`","tuple","[","int","]","`",")",":","stride","size","for","patch","embed3d","."]
code: def _freeze_stages(self):
      if self.frozen_stages >= 0:
          self.patch_embed.eval()
          for param in self.patch_embed.parameters():
              param.requires_grad = False
  
      if self.frozen_stages >= 1:
          self.pos_drop.eval()
          for i in range(0, self.frozen_stages):
              m = self.layers[i]
              m.eval()
              for param in m.parameters():
                  param.requires_grad = False
  
imports: import torch
  from torch import nn
  from torch.utils import model_zoo
  from einops import rearrange
  from towhee.models.layers.patch_embed3d import PatchEmbed3D
  from towhee.models.layers.patch_merging3d import PatchMerging3D
  from towhee.models.video_swin_transformer.video_swin_transformer_block import VideoSwinTransformerBlock
  from towhee.models.video_swin_transformer import get_configs
  from towhee.models.utils.init_vit_weights import init_vit_weights
  from collections import OrderedDict
  import logging
label_desc: Use image node_id 2 for calling the VideoSwinTransformer obj's underlying member method code with example usage: obj._freeze_stages() without return types