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 forward(
      self,
      hidden_states: torch.FloatTensor,
      num_frames: int,
      encoder_hidden_states: Optional[torch.FloatTensor] = None,
  ) -> torch.FloatTensor:
      # Notice that normalization is always applied before the real computation in the following blocks.
      # 0. Self-Attention
      batch_size = hidden_states.shape[0]
  
      batch_frames, seq_length, channels = hidden_states.shape
      batch_size = batch_frames // num_frames
  
      hidden_states = hidden_states[None, :].reshape(
          batch_size, num_frames, seq_length, channels
      )
      hidden_states = hidden_states.permute(0, 2, 1, 3)
      hidden_states = hidden_states.reshape(
          batch_size * seq_length, num_frames, channels
      )
  
      residual = hidden_states
      hidden_states = self.norm_in(hidden_states)
  
      if self._chunk_size is not None:
          hidden_states = _chunked_feed_forward(
              self.ff_in,
              hidden_states,
              self._chunk_dim,
              self._chunk_size,
          )
      else:
          hidden_states = self.ff_in(hidden_states)
  
      if self.is_res:
          hidden_states = hidden_states + residual
  
      norm_hidden_states = self.norm1(hidden_states)
      attn_output = self.attn1(
          norm_hidden_states, encoder_hidden_states=None
      )
      hidden_states = attn_output + hidden_states
  
      # 3. Cross-Attention
      if self.attn2 is not None:
          norm_hidden_states = self.norm2(hidden_states)
          attn_output = self.attn2(
              norm_hidden_states,
              encoder_hidden_states=encoder_hidden_states,
          )
          hidden_states = attn_output + hidden_states
  
      # 4. Feed-forward
      norm_hidden_states = self.norm3(hidden_states)
  
      if self._chunk_size is not None:
          ff_output = _chunked_feed_forward(
              self.ff,
              norm_hidden_states,
              self._chunk_dim,
              self._chunk_size,
          )
      else:
          ff_output = self.ff(norm_hidden_states)
  
      if self.is_res:
          hidden_states = ff_output + hidden_states
      else:
          hidden_states = ff_output
  
      hidden_states = hidden_states[None, :].reshape(
          batch_size, seq_length, num_frames, channels
      )
      hidden_states = hidden_states.permute(0, 2, 1, 3)
      hidden_states = hidden_states.reshape(
          batch_size * num_frames, seq_length, channels
      )
  
      return hidden_states
  
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 3 for calling the TemporalBasicTransformerBlock obj's underlying member method code with example usage: obj.forward(hidden_states, num_frames, encoder_hidden_states) and returns: hidden_states