code: def create_lsun_wide(
      tfrecord_dir, lmdb_dir, width=512, height=384, max_images=None
  ):
      assert width == 2 ** int(np.round(np.log2(width)))
      assert height <= width
      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, print_progress=False
          ) 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))
                          )
  
                      ch = int(
                          np.round(width * img.shape[0] / img.shape[1])
                      )
                      if img.shape[1] < width or ch < height:
                          continue
  
                      img = img[
                          (img.shape[0] - ch)
                          // 2 : (img.shape[0] + ch)
                          // 2
                      ]
                      img = PIL.Image.fromarray(img, "RGB")
                      img = img.resize(
                          (width, height), PIL.Image.ANTIALIAS
                      )
                      img = np.asarray(img)
                      img = img.transpose([2, 0, 1])  # HWC => CHW
  
                      canvas = np.zeros(
                          [3, width, width], dtype=np.uint8
                      )
                      canvas[
                          :,
                          (width - height) // 2 : (width + height) // 2,
                      ] = img
                      tfr.add_image(canvas)
                      print(
                          "\r%d / %d => %d "
                          % (idx + 1, total_images, tfr.cur_images),
                          end="",
                      )
  
                  except:
                      print(sys.exc_info()[1])
                  if tfr.cur_images == max_images:
                      break
      print()
  
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 11 for calling a global function with example usage: create_lsun_wide(tfrecord_dir, lmdb_dir, width, height, max_images) without return types