docstr: Args:
      med_config (str): path for the mixture of encoder-decoder model's configuration file
      image_size (int): input image size
      vit (str): model size of vision transformer
docstr_tok: ["Args",":","med_config","(","str",")",":","path","for","the","mixture","of","encoder-decoder","model","'s","configuration","file","image_size","(","int",")",":","input","image","size","vit","(","str",")",":","model","size","of","vision","transformer"]
code: def __init__(
      self,
      med_config="configs/med_config.json",
      image_size=384,
      vit="base",
      vit_grad_ckpt=False,
      vit_ckpt_layer=0,
      embed_dim=256,
      queue_size=57600,
      momentum=0.995,
      negative_all_rank=False,
  ):
      """
      Args:
          med_config (str): path for the mixture of encoder-decoder model's configuration file
          image_size (int): input image size
          vit (str): model size of vision transformer
      """
      super().__init__()
  
      self.visual_encoder, vision_width = create_vit(
          vit, image_size, vit_grad_ckpt, vit_ckpt_layer
      )
      self.tokenizer = init_tokenizer()
      med_config = BertConfig.from_json_file(med_config)
      med_config.encoder_width = vision_width
      self.text_encoder = BertModel(
          config=med_config, add_pooling_layer=False
      )
  
      text_width = self.text_encoder.config.hidden_size
  
      self.vision_proj = nn.Linear(vision_width, embed_dim)
      self.text_proj = nn.Linear(text_width, embed_dim)
  
      self.itm_head = nn.Linear(text_width, 2)
  
      # create momentum encoders
      self.visual_encoder_m, vision_width = create_vit(vit, image_size)
      self.vision_proj_m = nn.Linear(vision_width, embed_dim)
      self.text_encoder_m = BertModel(
          config=med_config, add_pooling_layer=False
      )
      self.text_proj_m = nn.Linear(text_width, embed_dim)
  
      self.model_pairs = [
          [self.visual_encoder, self.visual_encoder_m],
          [self.vision_proj, self.vision_proj_m],
          [self.text_encoder, self.text_encoder_m],
          [self.text_proj, self.text_proj_m],
      ]
      self.copy_params()
  
      # create the queue
      self.register_buffer(
          "image_queue", torch.randn(embed_dim, queue_size)
      )
      self.register_buffer(
          "text_queue", torch.randn(embed_dim, queue_size)
      )
      self.register_buffer(
          "idx_queue", torch.full((1, queue_size), -100)
      )
      self.register_buffer(
          "ptr_queue", torch.zeros(1, dtype=torch.long)
      )
  
      self.image_queue = nn.functional.normalize(
          self.image_queue, dim=0
      )
      self.text_queue = nn.functional.normalize(self.text_queue, dim=0)
  
      self.queue_size = queue_size
      self.momentum = momentum
      self.temp = nn.Parameter(0.07 * torch.ones([]))
  
      self.negative_all_rank = negative_all_rank
  
imports: from models.med import BertConfig, BertModel
  from transformers import BertTokenizer
  import torch
  from torch import nn
  import torch.nn.functional
  from models.blip import create_vit, init_tokenizer, load_checkpoint
label_desc: Use image node_id 1 to create a new BLIP_Retrieval object from inherited base classes: nn with example: obj = BLIP_Retrieval(med_config, image_size, vit, vit_grad_ckpt, vit_ckpt_layer, embed_dim, queue_size, momentum, negative_all_rank)