code: def create_lsun(
      tfrecord_dir, lmdb_dir, resolution=256, max_images=None
  ):
      print('Loading LSUN dataset from "%s"' % lmdb_dir)
      import lmdb  # pip install lmdb # pylint: disable=import-error
      import cv2  # pip install opencv-python
      import io
  
      with lmdb.open(lmdb_dir, readonly=True).begin(write=False) as txn:
          total_images = txn.stat()[
              "entries"
          ]  # pylint: disable=no-value-for-parameter
          if max_images is None:
              max_images = total_images
          with TFRecordExporter(tfrecord_dir, max_images) as tfr:
              for _idx, (_key, value) in enumerate(txn.cursor()):
                  try:
                      try:
                          img = cv2.imdecode(
                              np.fromstring(value, dtype=np.uint8), 1
                          )
                          if img is None:
                              raise IOError("cv2.imdecode failed")
                          img = img[:, :, ::-1]  # BGR => RGB
                      except IOError:
                          img = np.asarray(
                              PIL.Image.open(io.BytesIO(value))
                          )
                      crop = np.min(img.shape[:2])
                      img = img[
                          (img.shape[0] - crop)
                          // 2 : (img.shape[0] + crop)
                          // 2,
                          (img.shape[1] - crop)
                          // 2 : (img.shape[1] + crop)
                          // 2,
                      ]
                      img = PIL.Image.fromarray(img, "RGB")
                      img = img.resize(
                          (resolution, resolution), PIL.Image.ANTIALIAS
                      )
                      img = np.asarray(img)
                      img = img.transpose([2, 0, 1])  # HWC => CHW
                      tfr.add_image(img)
                  except:
                      print(sys.exc_info()[1])
                  if tfr.cur_images == max_images:
                      break
  
imports: import os
  import sys
  import glob
  import argparse
  import threading
  import six.moves.queue
  import traceback
  import numpy
  import tensorflow
  import PIL.Image
  import dnnlib.tflib
  from training import dataset
label_desc: Use image node_id 10 for calling a global function with example usage: create_lsun(tfrecord_dir, lmdb_dir, resolution, max_images) without return types