class_docstr: BLIP2 Vicuna model.
  Supported model types:
      - vicuna7b
      - vicuna13b
  Usage:
      >>> from lavis.models import load_model
      >>> model = load_model("blip2_vicuna_xinstruct", "vicuna7b")
class_docstr_tok: ["BLIP2","Vicuna","model",".","Supported","model","types",":","-","vicuna7b","-","vicuna13b","Usage",":",">",">",">","from","lavis.models","import","load_model",">",">",">","model","=","load_model","(","``","blip2_vicuna_xinstruct","''",",","``","vicuna7b","''",")"]
code: def init_ln(cls, num_features, load_ln_path=False, load_ln_type=""):
      ln = LayerNorm(num_features)
      if load_ln_path and load_ln_type:
          url_or_filename = load_ln_path
          logging.info(
              f"Loading pretrained layer norm weights from {url_or_filename} of type {load_ln_type}"
          )
          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 load_ln_type:
              load_ln_type = (
                  f"{load_ln_type}_ln"
                  if "vision" not in load_ln_type
                  else "ln_vision"
              )
          loaded_state_dict = {}
          if "model" in checkpoint:
              checkpoint = checkpoint["model"]
          for k in checkpoint.keys():
              if load_ln_type in k:
                  loaded_state_dict[
                      ".".join(k.split(".")[1:])
                  ] = checkpoint[k]
          ln.load_state_dict(loaded_state_dict, strict=False)
  
      return ln
  
imports: import logging
  import string
  from packaging import version
  import os
  from omegaconf import OmegaConf
  import torch
  from torch.cuda.amp import autocast
  import torch.nn
  from torch.nn.modules.module import _IncompatibleKeys
  from peft import get_peft_model, LoraConfig, TaskType
  import transformers
  import random
  from lavis.common.registry import registry
  from lavis.models.base_model import BaseModel
  from lavis.models.blip2_models.blip2 import Blip2Base, disabled_train, LayerNorm
  from lavis.models.ulip_models.ULIP_models import ULIP_PointBERT
  from lavis.tasks.multimodal_classification import MultimodalClassificationTask
  from lavis.common.utils import is_url
  from lavis.models.blip2_models.Qformer import BertConfig, BertLMHeadModel
  from lavis.common.dist_utils import download_cached_file
  from lavis.processors.blip_processors import BlipCaptionProcessor
label_desc: Use image node_id 17 for calling the Blip2VicunaXInstruct obj's underlying member method code with example usage: obj.init_ln(cls, num_features, load_ln_path, load_ln_type) and returns: ln