code: def test_feature_extractor(self):
      from PIL import Image
      from lavis.models import load_model_and_preprocess
  
      raw_image = Image.open("docs/_static/merlion.png").convert("RGB")
      caption = "a large fountain spewing water into the air"
  
      model, vis_processors, txt_processors = load_model_and_preprocess(
          "blip_feature_extractor",
          model_type="base",
          is_eval=True,
          device=device,
      )
  
      image = vis_processors["eval"](raw_image).unsqueeze(0).to(device)
      text_input = txt_processors["eval"](caption)
  
      sample = {"image": image, "text_input": [text_input]}
  
      features_multimodal = model.extract_features(sample)
      features_text = model.extract_features(sample, mode="text")
      features_image = model.extract_features(sample, mode="image")
  
      assert features_multimodal.image_embeds.shape == torch.Size(
          [1, 197, 768]
      )
      assert features_multimodal.multimodal_embeds.shape == torch.Size(
          [1, 12, 768]
      )
  
      assert features_text.text_embeds.shape == torch.Size([1, 12, 768])
      assert features_text.text_embeds_proj.shape == torch.Size(
          [1, 12, 256]
      )
  
      assert features_image.image_embeds.shape == torch.Size(
          [1, 197, 768]
      )
      assert features_image.image_embeds_proj.shape == torch.Size(
          [1, 197, 256]
      )
  
      assert torch.mean(
          features_multimodal.image_embeds
      ).item() == pytest.approx(-0.02032, precision)
      assert torch.mean(
          features_multimodal.multimodal_embeds
      ).item() == pytest.approx(-0.00095, precision)
  
      assert torch.mean(
          features_text.text_embeds
      ).item() == pytest.approx(-6.6098e-5, precision)
      assert torch.mean(
          features_text.text_embeds_proj
      ).item() == pytest.approx(-0.002149, precision)
  
      assert torch.mean(
          features_image.image_embeds
      ).item() == pytest.approx(-0.02032, precision)
      assert torch.mean(
          features_image.image_embeds_proj
      ).item() == pytest.approx(-0.0023, precision)
  
file_path: lavis/tests/models/test_blip.py
imports: import pytest
  import torch
  from lavis.models import load_model, load_model_and_preprocess
  from PIL import Image
label_desc: Use image node_id 7 for calling the TestBlip obj's underlying member method code with example usage: obj.test_feature_extractor() without return types