class_docstr: A basic Transformer block for video like data.
  
  Parameters:
      dim (`int`): The number of channels in the input and output.
      time_mix_inner_dim (`int`): The number of channels for temporal attention.
      num_attention_heads (`int`): The number of heads to use for multi-head attention.
      attention_head_dim (`int`): The number of channels in each head.
      cross_attention_dim (`int`, *optional*): The size of the encoder_hidden_states vector for cross attention.
class_docstr_tok: ["A","basic","Transformer","block","for","video","like","data",".","Parameters",":","dim","(","`","int","`",")",":","The","number","of","channels","in","the","input","and","output",".","time_mix_inner_dim","(","`","int","`",")",":","The","number","of","channels","for","temporal","attention",".","num_attention_heads","(","`","int","`",")",":","The","number","of","heads","to","use","for","multi-head","attention",".","attention_head_dim","(","`","int","`",")",":","The","number","of","channels","in","each","head",".","cross_attention_dim","(","`","int","`",",","*","optional","*",")",":","The","size","of","the","encoder_hidden_states","vector","for","cross","attention","."]
code: def __init__(
      self,
      dim: int,
      time_mix_inner_dim: int,
      num_attention_heads: int,
      attention_head_dim: int,
      cross_attention_dim: Optional[int] = None,
  ):
      super().__init__()
      self.is_res = dim == time_mix_inner_dim
  
      self.norm_in = nn.LayerNorm(dim)
  
      # Define 3 blocks. Each block has its own normalization layer.
      # 1. Self-Attn
      self.norm_in = nn.LayerNorm(dim)
      self.ff_in = FeedForward(
          dim,
          dim_out=time_mix_inner_dim,
          activation_fn="geglu",
      )
  
      self.norm1 = nn.LayerNorm(time_mix_inner_dim)
      self.attn1 = Attention(
          query_dim=time_mix_inner_dim,
          heads=num_attention_heads,
          dim_head=attention_head_dim,
          cross_attention_dim=None,
      )
  
      # 2. Cross-Attn
      if cross_attention_dim is not None:
          # We currently only use AdaLayerNormZero for self attention where there will only be one attention block.
          # I.e. the number of returned modulation chunks from AdaLayerZero would not make sense if returned during
          # the second cross attention block.
          self.norm2 = nn.LayerNorm(time_mix_inner_dim)
          self.attn2 = Attention(
              query_dim=time_mix_inner_dim,
              cross_attention_dim=cross_attention_dim,
              heads=num_attention_heads,
              dim_head=attention_head_dim,
          )  # is self-attn if encoder_hidden_states is none
      else:
          self.norm2 = None
          self.attn2 = None
  
      # 3. Feed-forward
      self.norm3 = nn.LayerNorm(time_mix_inner_dim)
      self.ff = FeedForward(time_mix_inner_dim, activation_fn="geglu")
  
      # let chunk size default to None
      self._chunk_size = None
      self._chunk_dim = None
  
imports: from typing import Any, Dict, Optional
  import torch
  import torch.nn.functional
  from torch import nn
  from ..utils import USE_PEFT_BACKEND
  from ..utils.torch_utils import maybe_allow_in_graph
  from .activations import GEGLU, GELU, ApproximateGELU
  from .attention_processor import Attention
  from .embeddings import SinusoidalPositionalEmbedding
  from .lora import LoRACompatibleLinear
  from .normalization import AdaLayerNorm, AdaLayerNormContinuous, AdaLayerNormZero, RMSNorm
label_desc: Use image node_id 1 to create a new TemporalBasicTransformerBlock object from inherited base classes: nn with example: obj = TemporalBasicTransformerBlock(dim, time_mix_inner_dim, num_attention_heads, attention_head_dim, cross_attention_dim)