class_docstr: Modified cross attention for BridgeFormer.
  
  Args:
      dim (`int`):
          Dimension of features.
      num_heads (`int`):
          Number of heads.
      qkv_bias (`bool`):
          If add bias to qkv.
      qk_scale (`float`):
          Number to scale qk.
      attn_drop (`float`):
          Drop rate of attention layer.
      proj_drop (`float`):
          Drop rate of projection layer.
class_docstr_tok: ["Modified","cross","attention","for","BridgeFormer",".","Args",":","dim","(","`","int","`",")",":","Dimension","of","features",".","num_heads","(","`","int","`",")",":","Number","of","heads",".","qkv_bias","(","`","bool","`",")",":","If","add","bias","to","qkv",".","qk_scale","(","`","float","`",")",":","Number","to","scale","qk",".","attn_drop","(","`","float","`",")",":","Drop","rate","of","attention","layer",".","proj_drop","(","`","float","`",")",":","Drop","rate","of","projection","layer","."]
code: def forward(self, x, question, einops_from, einops_to, **einops_dims):
      h = self.num_heads
      # project x to q, k, v vaalues
      q = self.q_question(question)
      k, v = self.kv_video(x).chunk(2, dim=-1)
      q, k, v = map(
          lambda t: rearrange(t, "b n (h d) -> (b h) n d", h=h),
          (q, k, v),
      )
  
      q *= self.scale
      cls_q = q[:, 0:1]
      q_ = q[:, 1:]
  
      cls_out = attn(cls_q, k, v)
  
      n_f = int(einops_dims["f"])
      q_ = q_.repeat_interleave(n_f, 0)
      k, v = map(
          lambda t: rearrange(
              t, f"{einops_from} -> {einops_to}", **einops_dims
          ),
          (k, v),
      )
  
      out = attn(q_, k, v)
      out = rearrange(
          out, f"{einops_to} -> {einops_from}", **einops_dims
      )
  
      # concat back the cls token
      out = torch.cat((cls_out, out), dim=1)
      # merge back the heads
      out = rearrange(out, "(b h) n d -> b n (h d)", h=h)
  
      # to out
      x = self.proj(out)
      x = self.proj_drop(x)
      return x
  
imports: from collections import OrderedDict
  from functools import partial
  import torch
  from einops import rearrange, repeat
  from timm.models.layers import DropPath, trunc_normal_
  from torch import einsum, nn
  from towhee.models.layers.mlp import Mlp
  from towhee.models.layers.patch_embed2d import PatchEmbed2D
  from towhee.models.utils.init_vit_weights import init_vit_weights
  from towhee.models.frozen_in_time.frozen_video_transformer import attn
label_desc: Use image node_id 2 for calling the CrossAttention obj's underlying member method code with example usage: obj.forward(x, question, einops_from, einops_to) and returns: x