code: def load_from_pretrained(
      self, url_or_filename, num_frames, num_patches
  ):
      if is_url(url_or_filename):
          cached_file = download_cached_file(
              url_or_filename, check_hash=False, progress=True
          )
          checkpoint = torch.load(cached_file, map_location="cpu")
      elif os.path.isfile(url_or_filename):
          checkpoint = torch.load(url_or_filename, map_location="cpu")
      else:
          raise RuntimeError("checkpoint url or path is invalid")
  
      if "model" in checkpoint:
          state_dict = checkpoint["model"]
      else:
          state_dict = checkpoint
  
      for key in list(state_dict.keys()):
          if "bert" in key:
              new_key = key.replace("bert.", "")
              state_dict[new_key] = state_dict[key]
              del state_dict[key]
  
      spatial_embed_key = "visual_encoder.model.pos_embed"
      temporal_embed_key = "visual_encoder.model.time_embed"
  
      ## Resizing spatial embeddings in case they don't match
      if num_patches + 1 != state_dict[spatial_embed_key].size(1):
          state_dict[spatial_embed_key] = resize_spatial_embedding(
              state_dict, spatial_embed_key, num_patches
          )
      else:
          logging.info(
              "The length of spatial position embedding matches. No need to resize."
          )
  
      ## Resizing time embeddings in case they don't match
      if temporal_embed_key in state_dict and num_frames != state_dict[
          temporal_embed_key
      ].size(1):
          state_dict[temporal_embed_key] = resize_temporal_embedding(
              state_dict, temporal_embed_key, num_frames
          )
      else:
          logging.info(
              "No temporal encoding found. Or the length of temporal position embedding matches. No need to resize."
          )
  
      msg = self.load_state_dict(state_dict, strict=False)
      logging.info("Missing keys {}".format(msg.missing_keys))
      logging.info("load checkpoint from %s" % url_or_filename)
  
      return msg
  
file_path: lavis/lavis/models/alpro_models/__init__.py
imports: import logging
  import os
  import torch
  import torch.nn.functional
  from lavis.common.dist_utils import download_cached_file
  from lavis.common.utils import is_url
  from lavis.models.base_model import BaseModel
  from transformers import BertTokenizer
label_desc: Use image node_id 2 for calling the AlproBase obj's underlying member method code with example usage: obj.load_from_pretrained(url_or_filename, num_frames, num_patches) and returns: msg