code: def from_config(cls, cfg=None):
      image_encoder = VisionTransformerEncoder.from_config(
          cfg, from_pretrained=True
      )
      config_text_encoder = BertConfig.from_json_file(
          get_abs_path(cfg["med_config_path"])
      )
      config_text_encoder.fusion_layer = 6
      text_encoder = BertForMaskedLM.from_pretrained(
          "bert-base-uncased", config=config_text_encoder
      )
  
      embed_dim = cfg.get("embed_dim", 256)
      max_txt_len = cfg.get("max_txt_len", 30)
  
      model = cls(
          image_encoder=image_encoder,
          text_encoder=text_encoder,
          embed_dim=embed_dim,
          max_txt_len=max_txt_len,
      )
  
      # load pre-trained weights
      pretrain_path = cfg.get("pretrained", None)
      if pretrain_path is not None:
          msg = model.load_from_pretrained(
              url_or_filename=pretrain_path, rename_text_keys=False
          )
      else:
          warnings.warn("No pretrained weights are loaded.")
  
      return model
  
file_path: lavis/lavis/models/albef_models/albef_feature_extractor.py
imports: import warnings
  import torch
  import torch.nn.functional
  from lavis.common.registry import registry
  from lavis.common.utils import get_abs_path
  from lavis.models.albef_models import AlbefBase
  from lavis.models.albef_models.albef_outputs import AlbefOutputFeatures
  from lavis.models.med import BertForMaskedLM
  from lavis.models.vit import VisionTransformerEncoder
  from torch import nn
  from transformers import BertConfig
label_desc: Use image node_id 3 for calling the AlbefFeatureExtractor obj's underlying member method code with example usage: obj.from_config(cls, cfg) and returns: model