import torch
from transformers import IdeficsForVisionText2Text, AutoProcessor, BitsAndBytesConfig
quantization_config = BitsAndBytesConfig(
     load_in_4bit=True,
     bnb_4bit_compute_dtype=torch.float16,
 )
processor = AutoProcessor.from_pretrained(checkpoint)
model = IdeficsForVisionText2Text.from_pretrained(
     checkpoint,
     quantization_config=quantization_config,
     device_map="auto"
 )