Commencing with the imports, in line (1), we import classes from the PIL (Pillow) module, which we use to create the image we want to render on the OLED display. We also import several other classes from the Luma module related to our SSD1306 OLED and its I2C interface (SPI is also imported for reference).
We see how to create an I2C instance in line (2) representing the interface that our OLED is connected to. Commented out is an SPI alternative. In line (3), we create an instance of ssd1306 that represents our OLED display and assign it to the device variable. If you are using a different OLED display than the SSD1306, you will need to identify and adjust the ssd1306 import line, and the device instance created in line (3):
from PIL import Image, ImageDraw, ImageFont # (1)
from luma.core.interface.serial import i2c, spi
from luma.core.render import canvas
from luma.oled.device import ssd1306
#...truncated...
# OLED display is using I2C at address 0x3C...