class_docstr: A retrival wrapper using mm_encoder as both video/text backbone.
  TODO: move formally.
code: def forward_video(
      self,
      vfeats,
      vmasks,
      caps,
      cmasks,
      output_hidden_states=False,
      **kwargs,
  ):
      input_ids = caps[:, :2]
  
      attention_mask = torch.cat(
          [cmasks[:, :1], vmasks, cmasks[:, 1:2]], dim=1
      )
  
      token_type_ids = torch.zeros(
          (vmasks.size(0), vmasks.size(1) + 2),
          dtype=torch.long,
          device=vmasks.device,
      )
  
      outputs = self.mm_encoder(
          input_ids=input_ids,
          input_video_embeds=vfeats,
          attention_mask=attention_mask,
          token_type_ids=token_type_ids,
          output_hidden_states=True,
      )
      video_outputs = outputs[0]
  
      if output_hidden_states:
          return video_outputs
  
      batch_size = cmasks.size(0)
  
      video_attention_mask = torch.cat(
          [
              torch.zeros(
                  (batch_size, 1),
                  dtype=torch.bool,
                  device=vmasks.device,
              ),
              vmasks,
              torch.ones(
                  (batch_size, 1),
                  dtype=torch.bool,
                  device=vmasks.device,
              ),
          ],
          dim=1,
      )
      assert video_outputs.size(1) == video_attention_mask.size(1)
  
      video_attention_mask = video_attention_mask.type(
          video_outputs.dtype
      ) / video_attention_mask.sum(1, keepdim=True)
  
      pooled_video = torch.bmm(
          video_outputs.transpose(2, 1),
          video_attention_mask.unsqueeze(2),
      ).squeeze(-1)
      return pooled_video
  
imports: import torch
  from torch import nn
  from .None import transformermodel
label_desc: Use image node_id 2 for calling the MMFusionShare obj's underlying member method code with example usage: obj.forward_video(vfeats, vmasks, caps, cmasks, output_hidden_states) and returns: pooled_video, video_outputs