class_docstr: Model builder for MViTv1 and MViTv2.
  
  "MViTv2: Improved Multiscale Vision Transformers for Classification and Detection"
  Yanghao Li, Chao-Yuan Wu, Haoqi Fan, Karttikeya Mangalam, Bo Xiong, Jitendra Malik, Christoph Feichtenhofer
  https://arxiv.org/abs/2112.01526
  "Multiscale Vision Transformers"
  Haoqi Fan, Bo Xiong, Karttikeya Mangalam, Yanghao Li, Zhicheng Yan, Jitendra Malik, Christoph Feichtenhofer
  https://arxiv.org/abs/2104.11227
class_docstr_tok: ["Model","builder","for","MViTv1","and","MViTv2",".","``","MViTv2",":","Improved","Multiscale","Vision","Transformers","for","Classification","and","Detection","''","Yanghao","Li",",","Chao-Yuan","Wu",",","Haoqi","Fan",",","Karttikeya","Mangalam",",","Bo","Xiong",",","Jitendra","Malik",",","Christoph","Feichtenhofer","https",":","\/\/arxiv.org\/abs\/2112.01526","''","Multiscale","Vision","Transformers","''","Haoqi","Fan",",","Bo","Xiong",",","Karttikeya","Mangalam",",","Yanghao","Li",",","Zhicheng","Yan",",","Jitendra","Malik",",","Christoph","Feichtenhofer","https",":","\/\/arxiv.org\/abs\/2104.11227"]
code: def forward(self, x, bboxes=None, return_attn=False):
      x = x[0]
      x, bcthw = self.patch_embed(x)
      bcthw = list(bcthw)
      if len(bcthw) == 4:  # Fix bcthw in case of 4D tensor
          bcthw.insert(2, torch.tensor(self.T))
      T, H, W = bcthw[-3], bcthw[-2], bcthw[-1]
      assert len(bcthw) == 5 and (T, H, W) == (
          self.T,
          self.H,
          self.W,
      ), bcthw
      B, N, C = x.shape
  
      s = 1 if self.cls_embed_on else 0
      if self.use_fixed_sincos_pos:
          x += self.pos_embed[:, s:, :]  # s: on/off cls token
  
      if self.cls_embed_on:
          cls_tokens = self.cls_token.expand(
              B, -1, -1
          )  # stole cls_tokens impl from Phil Wang, thanks
          if self.use_fixed_sincos_pos:
              cls_tokens = cls_tokens + self.pos_embed[:, :s, :]
          x = torch.cat((cls_tokens, x), dim=1)
  
      if self.use_abs_pos:
          if self.sep_pos_embed:
              pos_embed = self.pos_embed_spatial.repeat(
                  1, self.patch_dims[0], 1
              ) + torch.repeat_interleave(
                  self.pos_embed_temporal,
                  self.patch_dims[1] * self.patch_dims[2],
                  dim=1,
              )
              if self.cls_embed_on:
                  pos_embed = torch.cat(
                      [self.pos_embed_class, pos_embed], 1
                  )
              x += self._get_pos_embed(pos_embed, bcthw)
          else:
              x += self._get_pos_embed(self.pos_embed, bcthw)
  
      if self.drop_rate:
          x = self.pos_drop(x)
  
      if self.norm_stem:
          x = self.norm_stem(x)
  
      thw = [T, H, W]
  
      if self.enable_rev:
          x = self._forward_reversible(x)
  
      else:
          for blk in self.blocks:
              x, thw = blk(x, thw)
  
          if self.enable_detection:
              assert not self.enable_rev
  
              x = self.norm(x)
              if self.cls_embed_on:
                  x = x[:, 1:]
  
              B, _, C = x.shape
              x = x.transpose(1, 2).reshape(
                  B, C, thw[0], thw[1], thw[2]
              )
  
              x = self.head([x], bboxes)
  
          else:
              if self.use_mean_pooling:
                  if self.cls_embed_on:
                      x = x[:, 1:]
                  x = x.mean(1)
                  x = self.norm(x)
              elif self.cls_embed_on:
                  x = self.norm(x)
                  x = x[:, 0]
              else:  # this is default, [norm->mean]
                  x = self.norm(x)
                  x = x.mean(1)
              x = self.head(x)
  
      return x
  
imports: import math
  from functools import partial
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.nn.init import trunc_normal_
  import slowfast.utils.logging
  import slowfast.utils.weight_init_helper
  from slowfast.models.attention import MultiScaleBlock
  from slowfast.models.batchnorm_helper import get_norm
  from slowfast.models.common import TwoStreamFusion
  from slowfast.models.reversible_mvit import ReversibleMViT
  from slowfast.models.utils import calc_mvit_feature_geometry, get_3d_sincos_pos_embed, round_width, validate_checkpoint_wrapper_import
  from .None import head_helper, operators, resnet_helper, stem_helper
  from .build import MODEL_REGISTRY
label_desc: Use image node_id 6 for calling the MViT obj's underlying member method code with example usage: obj.forward(x, bboxes, return_attn) and returns: x