code: def __init__(
      self,
      dim,
      n_heads,
      d_head,
      dropout=0.0,
      context_dim=None,
      gated_ff=True,
      checkpoint=True,
      timesteps=None,
      ff_in=False,
      inner_dim=None,
      attn_mode="softmax",
      disable_self_attn=False,
      disable_temporal_crossattention=False,
      switch_temporal_ca_to_sa=False,
  ):
      super().__init__()
  
      attn_cls = self.ATTENTION_MODES[attn_mode]
  
      self.ff_in = ff_in or inner_dim is not None
      if inner_dim is None:
          inner_dim = dim
  
      assert int(n_heads * d_head) == inner_dim
  
      self.is_res = inner_dim == dim
  
      if self.ff_in:
          self.norm_in = nn.LayerNorm(dim)
          self.ff_in = FeedForward(
              dim, dim_out=inner_dim, dropout=dropout, glu=gated_ff
          )
  
      self.timesteps = timesteps
      self.disable_self_attn = disable_self_attn
      if self.disable_self_attn:
          self.attn1 = attn_cls(
              query_dim=inner_dim,
              heads=n_heads,
              dim_head=d_head,
              context_dim=context_dim,
              dropout=dropout,
          )  # is a cross-attention
      else:
          self.attn1 = attn_cls(
              query_dim=inner_dim,
              heads=n_heads,
              dim_head=d_head,
              dropout=dropout,
          )  # is a self-attention
  
      self.ff = FeedForward(
          inner_dim, dim_out=dim, dropout=dropout, glu=gated_ff
      )
  
      if disable_temporal_crossattention:
          if switch_temporal_ca_to_sa:
              raise ValueError
          else:
              self.attn2 = None
      else:
          self.norm2 = nn.LayerNorm(inner_dim)
          if switch_temporal_ca_to_sa:
              self.attn2 = attn_cls(
                  query_dim=inner_dim,
                  heads=n_heads,
                  dim_head=d_head,
                  dropout=dropout,
              )  # is a self-attention
          else:
              self.attn2 = attn_cls(
                  query_dim=inner_dim,
                  context_dim=context_dim,
                  heads=n_heads,
                  dim_head=d_head,
                  dropout=dropout,
              )  # is self-attn if context is none
  
      self.norm1 = nn.LayerNorm(inner_dim)
      self.norm3 = nn.LayerNorm(inner_dim)
      self.switch_temporal_ca_to_sa = switch_temporal_ca_to_sa
  
      self.checkpoint = checkpoint
      if self.checkpoint:
          print(f"{self.__class__.__name__} is using checkpointing")
  
file_path: generative-models/sgm/modules/video_attention.py
imports: import torch
  from ..modules.attention import *
  from ..modules.diffusionmodules.util import AlphaBlender, linear, timestep_embedding
label_desc: Use image node_id 1 to create a new VideoTransformerBlock object from inherited base classes: nn with example: obj = VideoTransformerBlock(dim, n_heads, d_head, dropout, context_dim, gated_ff, checkpoint, timesteps, ff_in, inner_dim, attn_mode, disable__attn, disable_temporal_crossattention, switch_temporal_ca_to_sa)