code: def read_images(lmdb_path, image_size):
      env = lmdb.open(
          lmdb_path,
          map_size=1099511627776,
          max_readers=100,
          readonly=True,
      )
      with env.begin(write=False) as transaction:
          cursor = transaction.cursor()
          for _, webp_data in cursor:
              img = Image.open(io.BytesIO(webp_data))
              width, height = img.size
              scale = image_size / min(width, height)
              img = img.resize(
                  (
                      int(round(scale * width)),
                      int(round(scale * height)),
                  ),
                  resample=Image.BOX,
              )
              arr = np.array(img)
              h, w, _ = arr.shape
              h_off = (h - image_size) // 2
              w_off = (w - image_size) // 2
              arr = arr[
                  h_off : h_off + image_size, w_off : w_off + image_size
              ]
              yield arr
  
file_path: improved-diffusion/datasets/lsun_bedroom.py
imports: import argparse
  import io
  import os
  from PIL import Image
  import lmdb
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: read_images(lmdb_path, image_size) without return types