class_docstr: A BertModel with shared prediction head on MFM-MLM.
class_docstr_tok: ["A","BertModel","with","shared","prediction","head","on","MFM-MLM","."]
code: def forward(
      self,
      input_ids=None,
      input_video_embeds=None,
      attention_mask=None,
      token_type_ids=None,
      position_ids=None,
      head_mask=None,
      inputs_embeds=None,
      masked_frame_labels=None,
      target_video_hidden_states=None,
      non_masked_frame_mask=None,
      masked_lm_labels=None,
      output_attentions=None,
      output_hidden_states=None,
      return_dict=None,
  ):
      return_dict = (
          return_dict
          if return_dict is not None
          else self.config.use_return_dict
      )
      if input_video_embeds is not None:
          video_tokens = self.videomlp(input_video_embeds)
      else:
          video_tokens = None
  
      if target_video_hidden_states is not None:
          target_video_hidden_states = self.videomlp(
              target_video_hidden_states
          )
  
          non_masked_frame_hidden_states = video_tokens.masked_select(
              non_masked_frame_mask.unsqueeze(-1)
          ).view(-1, self.hidden_size)
  
      outputs = self.bert(
          input_ids,
          video_tokens,
          attention_mask=attention_mask,
          token_type_ids=token_type_ids,
          position_ids=position_ids,
          head_mask=head_mask,
          inputs_embeds=inputs_embeds,
          output_attentions=output_attentions,
          output_hidden_states=output_hidden_states,
          return_dict=return_dict,
      )
  
      sequence_output = outputs[0]
  
      mfm_scores, prediction_scores = None, None
      if (
          masked_frame_labels is not None
          and masked_lm_labels is not None
      ):
          # split the sequence.
          text_offset = masked_frame_labels.size(1) + 1  # [CLS]
          video_sequence_output = sequence_output[
              :, 1:text_offset
          ]  # remove [SEP] as not in video_label.
          text_sequence_output = torch.cat(
              [
                  sequence_output[:, :1],
                  sequence_output[:, text_offset:],
              ],
              dim=1,
          )
  
          hidden_size = video_sequence_output.size(-1)
          selected_video_output = video_sequence_output.masked_select(
              masked_frame_labels.unsqueeze(-1)
          ).view(-1, hidden_size)
  
          # only compute select tokens to training to speed up.
          hidden_size = text_sequence_output.size(-1)
          # masked_lm_labels = masked_lm_labels.reshape(-1)
          labels_mask = masked_lm_labels != -100
  
          selected_text_output = text_sequence_output.masked_select(
              labels_mask.unsqueeze(-1)
          ).view(-1, hidden_size)
          mfm_scores, prediction_scores = self.cls(
              selected_video_output,
              target_video_hidden_states,
              non_masked_frame_hidden_states,
              selected_text_output,
          )
  
      output = (
          mfm_scores,
          prediction_scores,
      ) + outputs
      return output
  
imports: import torch
  from torch import nn
  from ..modules import VideoTokenMLP, MMBertEmbeddings
label_desc: Use image node_id 3 for calling the MMBertForMFMMLM obj's underlying member method code with example usage: obj.forward(input_ids, input_video_embeds, attention_mask, token_type_ids, position_ids, head_mask, inputs_embeds, masked_frame_labels, target_video_hidden_states, non_masked_frame_mask, masked_lm_labels, output_attentions, output_hidden_states, return_dict) and returns: output