class_docstr: BLIP VQA models.
  
  Supported model types:
      - base: vqa model initialized with pre-trained BLIP base model on 115M image-text pairs after CapFilt; not fine-tuned.
      - vqav2: fine-tuned BLIP base model on VQA v2.0 dataset.
  
  Usage:
      >>> from lavis.models import load_model
      >>> model = load_model("blip_vqa", "vqav2")
      >>> model = load_model("blip_vqa", "okvqa")
      >>> model = load_model("blip_vqa", "aokvqa")
class_docstr_tok: ["BLIP","VQA","models",".","Supported","model","types",":","-","base",":","vqa","model","initialized","with","pre-trained","BLIP","base","model","on","115M","image-text","pairs","after","CapFilt",";","not","fine-tuned",".","-","vqav2",":","fine-tuned","BLIP","base","model","on","VQA","v2.0","dataset",".","Usage",":",">",">",">","from","lavis.models","import","load_model",">",">",">","model","=","load_model","(","``","blip_vqa","''",",","``","vqav2","''",")",">",">",">","model","=","load_model","(","``","blip_vqa","''",",","``","okvqa","''",")",">",">",">","model","=","load_model","(","``","blip_vqa","''",",","``","aokvqa","''",")"]
code: def _generate_answers(
      self, samples, num_beams=3, max_length=10, min_length=1
  ):
      encoder_out, _ = self.forward_encoder(samples)
  
      question_output = encoder_out
  
      question_states = (
          question_output.last_hidden_state.repeat_interleave(
              num_beams, dim=0
          )
      )
      question_atts = torch.ones(
          question_states.size()[:-1], dtype=torch.long
      ).to(self.device)
  
      model_kwargs = {
          "encoder_hidden_states": question_states,
          "encoder_attention_mask": question_atts,
      }
  
      bsz = samples["image"].size(0)
      bos_ids = torch.full(
          (bsz, 1),
          fill_value=self.tokenizer.bos_token_id,
          device=self.device,
      )
  
      outputs = self.text_decoder.generate(
          input_ids=bos_ids,
          max_length=max_length,
          min_length=min_length,
          num_beams=num_beams,
          eos_token_id=self.tokenizer.sep_token_id,
          pad_token_id=self.tokenizer.pad_token_id,
          **model_kwargs,
      )
  
      # collect answers
      answers = []
      for output in outputs:
          answer = self.tokenizer.decode(
              output, skip_special_tokens=True
          )
          answers.append(answer)
  
      return answers
  
file_path: lavis/lavis/models/blip_models/blip_vqa.py
imports: import torch
  import torch.nn.functional
  from lavis.common.registry import registry
  from lavis.models.base_model import tile
  from lavis.models.blip_models.blip import BlipBase
  from lavis.models.blip_models.blip_outputs import BlipOutput, BlipIntermediateOutput
  from lavis.models.med import XBertEncoder, XBertLMHeadDecoder
  from lavis.models.vit import VisionTransformerEncoder
label_desc: Use image node_id 6 for calling the BlipVQA obj's underlying member method code with example usage: obj._generate_answers(samples, num_beams, max_length, min_length) and returns: answers