code: def from_config(cls, cfg):
      # vision encoder
      visual_encoder_config = node_to_dict(cfg.timesformer)
      visual_encoder = TimeSformer(**visual_encoder_config)
  
      # text encoder
      text_encoder = XBertEncoder.from_config(cfg)
  
      num_classes = cfg.get("num_classes", -1)
      hidden_size = cfg.get("hidden_size", 768)
  
      model = cls(
          visual_encoder=visual_encoder,
          text_encoder=text_encoder,
          hidden_size=hidden_size,
          num_classes=num_classes,
      )
  
      num_patches = (
          visual_encoder_config["image_size"]
          // visual_encoder_config["patch_size"]
      ) ** 2
      num_frames = visual_encoder_config["n_frms"]
  
      model.load_checkpoint_from_config(
          cfg, num_frames=num_frames, num_patches=num_patches
      )
  
      return model
  
file_path: lavis/lavis/models/alpro_models/alpro_qa.py
imports: from warnings import warn
  import torch
  import torch.nn.functional
  from lavis.common.config import node_to_dict
  from lavis.common.registry import registry
  from lavis.models.alpro_models import AlproBase
  from lavis.models.alpro_models.alpro_outputs import AlproIntermediateOutput, AlproOutputWithLogits
  from lavis.models.med import XBertEncoder
  from lavis.models.timesformer.vit import TimeSformer
  from torch import nn
label_desc: Use image node_id 4 for calling the AlproQA obj's underlying member method code with example usage: obj.from_config(cls, cfg) and returns: model