code: def __init__(
      self,
      dim,
      dim_out,
      num_heads,
      input_size,
      mlp_ratio=4.0,
      qkv_bias=False,
      qk_scale=None,
      drop_rate=0.0,
      drop_path=0.0,
      layer_scale_init_value=0.0,
      act_layer=nn.GELU,
      norm_layer=nn.LayerNorm,
      up_rate=None,
      kernel_q=(1, 1, 1),
      kernel_kv=(1, 1, 1),
      stride_q=(1, 1, 1),
      stride_kv=(1, 1, 1),
      mode="conv",
      has_cls_embed=True,
      pool_first=False,
      rel_pos_spatial=False,
      rel_pos_temporal=False,
      rel_pos_zero_init=False,
      residual_pooling=False,
      dim_mul_in_att=False,
      separate_qkv=False,
  ):
      super().__init__()
      self.dim = dim
      self.dim_out = dim_out
      self.norm1 = norm_layer(dim)
      self.dim_mul_in_att = dim_mul_in_att
      kernel_skip = [s + 1 if s > 1 else s for s in stride_q]
      stride_skip = stride_q
      padding_skip = [int(skip // 2) for skip in kernel_skip]
      att_dim = dim_out if dim_mul_in_att else dim
      self.attn = MultiScaleAttention(
          dim,
          att_dim,
          num_heads=num_heads,
          input_size=input_size,
          qkv_bias=qkv_bias,
          drop_rate=drop_rate,
          kernel_q=kernel_q,
          kernel_kv=kernel_kv,
          stride_q=stride_q,
          stride_kv=stride_kv,
          norm_layer=norm_layer,
          has_cls_embed=has_cls_embed,
          mode=mode,
          pool_first=pool_first,
          rel_pos_spatial=rel_pos_spatial,
          rel_pos_temporal=rel_pos_temporal,
          rel_pos_zero_init=rel_pos_zero_init,
          residual_pooling=residual_pooling,
          separate_qkv=separate_qkv,
      )
      self.drop_path = (
          DropPath(drop_path) if drop_path > 0.0 else nn.Identity()
      )
      self.norm2 = norm_layer(att_dim)
      mlp_hidden_dim = int(att_dim * mlp_ratio)
      self.has_cls_embed = has_cls_embed
      # TODO: check the use case for up_rate, and merge the following lines
      if up_rate is not None and up_rate > 1:
          mlp_dim_out = dim * up_rate
      else:
          mlp_dim_out = dim_out
      self.mlp = Mlp(
          in_features=att_dim,
          hidden_features=mlp_hidden_dim,
          out_features=mlp_dim_out,
          act_layer=act_layer,
          drop_rate=drop_rate,
      )
      if layer_scale_init_value > 0:
          self.gamma_1 = nn.Parameter(
              layer_scale_init_value * torch.ones((dim)),
              requires_grad=True,
          )
          self.gamma_2 = nn.Parameter(
              layer_scale_init_value * torch.ones((dim_out)),
              requires_grad=True,
          )
      else:
          self.gamma_1, self.gamma_2 = None, None
  
      if dim != dim_out:
          self.proj = nn.Linear(dim, dim_out)
  
      self.pool_skip = (
          nn.MaxPool3d(
              kernel_skip, stride_skip, padding_skip, ceil_mode=False
          )
          if len(stride_skip) > 0 and numpy.prod(stride_skip) > 1
          else None
      )
  
file_path: SlowFast/slowfast/models/attention.py
imports: import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.nn.init import trunc_normal_
  from slowfast.models.common import DropPath, Mlp
label_desc: Use image node_id 1 to create a new MultiScaleBlock object from inherited base classes: nn with example: obj = MultiScaleBlock(dim, dim_out, num_heads, input_size, mlp_ratio, qkv_bias, qk_scale, drop_rate, drop_path, layer_scale_init_value, act_layer, norm_layer, up_rate, kernel_q, kernel_kv, stride_q, stride_kv, mode, has_cls_embed, pool_first, rel_pos_spatial, rel_pos_temporal, rel_pos_zero_init, residual_pooling, dim_mul_in_att, separate_qkv)