class_docstr: MMT VID model
  Args:
      expert_dims (Dict): dim of each expert model
      vid_bert_config (Any): vid bert config
      same_dim (int): reduce to same dim
      hidden_size (int): hidden size
code: def forward(
      self,
      features,  # embs from pretrained models {modality: (bs, ntok, embdim)}
      features_t,  # timings {modality: (bs, ntok)} each value is (emb_t_start + emb_t_end) / 2
      features_ind,  # mask (modality: (bs, ntok))
      features_maxp=None,
  ):
      device = self.device
      experts_feats = dict(features)
      experts_feats_t = dict(features_t)
      experts_feats_ind = dict(features_ind)
      ind = (
          {}
      )  # 1 if there is at least one non-pad token in this modality
      for mod in self.modalities:
          ind[mod] = torch.max(experts_feats_ind[mod], 1)[0]
  
      for mod in self.modalities:
          layer = self.video_dim_reduce[mod]
          experts_feats[mod] = layer(experts_feats[mod])
      bs = next(iter(features.values())).size(0)
      ids_size = (bs,)
      input_ids_list = []
      token_type_ids_list = []  # Modality id
      # Position (0 = no position, 1 = unknown, >1 = valid position)
      position_ids_list = []
      features_list = []  # Semantics
      attention_mask_list = []  # Valid token or not
  
      modality_to_tok_map = OrderedDict()
  
      # 0=[CLS] 1=[SEP] 2=[AGG] 3=[MAXP] 4=[MNP] 5=[VLAD] 6=[FEA]
      # [CLS] token
      tok_id = 0
      input_ids_list.append(torch.full(ids_size, 0, dtype=torch.long))
      token_type_ids_list.append(
          torch.full(ids_size, 0, dtype=torch.long)
      )
      position_ids_list.append(
          torch.full(ids_size, 0, dtype=torch.long).to(device)
      )
      features_list.append(
          torch.full((bs, self.hidden_size), 0, dtype=torch.float).to(
              device
          )
      )
      attention_mask_list.append(
          torch.full(ids_size, 1, dtype=torch.long).to(device)
      )
  
      # Number of temporal tokens per modality
      max_expert_tokens = OrderedDict()
      for modality in self.modalities:
          max_expert_tokens[modality] = experts_feats[modality].size()[
              1
          ]
  
      # Clamp the position encoding to [0, max_position_embedding - 1]
      max_pos = self.vid_bert_config.max_position_embeddings - 1
      for modality in self.modalities:
          experts_feats_t[modality].clamp_(min=0, max=max_pos)
          experts_feats_t[modality] = (
              experts_feats_t[modality].long().to(device)
          )
  
      for modality in self.modalities:
          token_type = self.expert_dims[modality]["idx"]
          tok_id += 1
  
          # add aggregation token
          modality_to_tok_map[modality] = tok_id
          input_ids_list.append(
              torch.full(ids_size, 2, dtype=torch.long)
          )
          token_type_ids_list.append(
              torch.full(ids_size, token_type, dtype=torch.long)
          )
          position_ids_list.append(
              torch.full(ids_size, 0, dtype=torch.long).to(device)
          )
          layer = self.video_dim_reduce[modality]
          if features_maxp is not None:
              feat_maxp = features_maxp[modality]
          else:
              feat_maxp = get_maxp(
                  features[modality], experts_feats_ind[modality]
              )
          features_list.append(layer(feat_maxp))
          attention_mask_list.append(
              ind[modality].to(dtype=torch.long).to(device)
          )
  
          # add expert tokens
          for frame_id in range(max_expert_tokens[modality]):
              tok_id += 1
              position_ids_list.append(
                  experts_feats_t[modality][:, frame_id]
              )
              input_ids_list.append(
                  torch.full(ids_size, 6, dtype=torch.long)
              )
              token_type_ids_list.append(
                  torch.full(ids_size, token_type, dtype=torch.long)
              )
              features_list.append(
                  experts_feats[modality][:, frame_id, :]
              )
              attention_mask_list.append(
                  experts_feats_ind[modality][:, frame_id].to(
                      dtype=torch.long
                  )
              )
  
      features = torch.stack(features_list, dim=1).to(self.device)
      input_ids = torch.stack(input_ids_list, dim=1).to(self.device)
      token_type_ids = torch.stack(token_type_ids_list, dim=1).to(
          self.device
      )
      position_ids = torch.stack(position_ids_list, dim=1).to(
          self.device
      )
      attention_mask = torch.stack(attention_mask_list, dim=1).to(
          self.device
      )
      vid_bert_output = self.vid_bert(
          input_ids,
          attention_mask=attention_mask,
          token_type_ids=token_type_ids,
          position_ids=position_ids,
          features=features,
      )
      last_layer = vid_bert_output[0]
      experts = []
      for modality in self.modalities:
          emb = last_layer[:, modality_to_tok_map[modality]]
          if self.same_dim != self.hidden_size:
              emb = self.video_dim_reduce_out[mod](emb)
          agg_tok_out = F.normalize(emb, dim=1)
          experts.append(agg_tok_out)  # (bs, embdim)
      experts = torch.cat(experts, dim=1)
      return experts
  
imports: import os
  import torch
  import torch.nn.functional
  from typing import Any, List, Dict
  from collections import OrderedDict
  from torch import nn
  from towhee.models.mdmmt.bert_mmt import BertMMT
label_desc: Use image node_id 3 for calling the MMTVID obj's underlying member method code with example usage: obj.forward(features, features_t, features_ind, features_maxp) and returns: experts