class_docstr: Loader that loads the captions of an image
class_docstr_tok: ["Loader","that","loads","the","captions","of","an","image"]
code: def load_model(self):
      try:
          import transformers
      except ImportError:
          raise ValueError(
              "`transformers` package not found, please install with "
              "`pip install transformers`."
          )
      self.set_context()
      if self.model:
          if (
              not self.load_in_8bit
              and str(self.model.device) != self.device_map[""]
          ):
              self.model.to(self.device)
          return self
      import torch
  
      with torch.no_grad():
          with self.context_class(self.device):
              context_class_cast = (
                  NullContext
                  if self.device == "cpu"
                  else torch.autocast
              )
              with context_class_cast(self.device):
                  if "blip2" in self.blip_processor.lower():
                      from transformers import (
                          Blip2Processor,
                          Blip2ForConditionalGeneration,
                      )
  
                      if self.load_half and not self.load_in_8bit:
                          self.processor = (
                              Blip2Processor.from_pretrained(
                                  self.blip_processor,
                                  device_map=self.device_map,
                              ).half()
                          )
                          self.model = Blip2ForConditionalGeneration.from_pretrained(
                              self.blip_model,
                              device_map=self.device_map,
                          ).half()
                      else:
                          self.processor = (
                              Blip2Processor.from_pretrained(
                                  self.blip_processor,
                                  load_in_8bit=self.load_in_8bit,
                                  device_map=self.device_map,
                              )
                          )
                          self.model = Blip2ForConditionalGeneration.from_pretrained(
                              self.blip_model,
                              load_in_8bit=self.load_in_8bit,
                              device_map=self.device_map,
                          )
                  else:
                      from transformers import (
                          BlipForConditionalGeneration,
                          BlipProcessor,
                      )
  
                      self.load_half = False  # not supported
                      self.processor = BlipProcessor.from_pretrained(
                          self.blip_processor,
                          device_map=self.device_map,
                      )
                      self.model = (
                          BlipForConditionalGeneration.from_pretrained(
                              self.blip_model,
                              device_map=self.device_map,
                          )
                      )
      return self
  
file_path: h2ogpt/src/image_captions.py
imports: from typing import List, Union, Any, Tuple
  import requests
  from langchain.docstore.document import Document
  from langchain.document_loaders import ImageCaptionLoader
  from utils import get_device, NullContext, clear_torch_cache
  from importlib.metadata import distribution, PackageNotFoundError
label_desc: Use image node_id 3 for calling the H2OImageCaptionLoader obj's underlying member method code with example usage: obj.load_model() and returns: self, self