code: def ingest_lsun(
      lsun_dir, category, dset, lbl_map, overwrite=False, png_conv=False
  ):
      """
      Save LSUN dataset as WEBP or PNG files and generate config and log files
  
      Arguments:
          lsun_dir (str): LSUN data directory
          category (str): LSUN category
          dset (str): dataset, "train", "val", or "test"
          lbl_map (dict(str:int)): maps a category to an integer
          overwrite (bool): whether to overwrite existing data
          png_conv (bool): whether to convert to PNG images
      """
      cfg_file = os.path.join(
          os.path.dirname(os.path.realpath(__file__)), "train.cfg"
      )
      log_file = os.path.join(lsun_dir, "train.log")
      dpath = (
          "test" if dset == "test" else "{0}_{1}".format(category, dset)
      )
      dpath = os.path.join(lsun_dir, dpath)
      manifest_file = "{}_index.csv".format(dpath)
  
      with open(cfg_file, "w") as f:
          f.write("manifest = [{}:{}]\n".format(dset, manifest_file))
          f.write("manifest_root = {}\n".format(lsun_dir))
          f.write("log = {}\n".format(log_file))
          f.write(
              "epochs = 25\nrng_seed = 0\nverbose = True\neval_freq = 0\n"
          )
          f.write("backend = gpu\nbatch_size = 64\n")
      if os.path.exists(manifest_file) and not overwrite:
          print("LSUN {0} {1} dataset ingested.".format(category, dset))
          print("Manifest file is: " + manifest_file)
          return manifest_file
      if os.path.exists(dpath):
          shutil.rmtree(dpath)
      if os.path.exists(manifest_file):
          os.remove(manifest_file)
      os.makedirs(dpath)
  
      print("Exporting images...")
      env = lmdb.open(
          dpath + "_lmdb",
          map_size=MAP_SIZE,
          max_readers=MAX_NUM_INGEST_PROC,
          readonly=True,
      )
      count, records = 0, [("@FILE", "STRING")]
      with env.begin(write=False) as txn:
          cursor = txn.cursor()
          for key, val in tqdm(cursor):
              image_out_path = os.path.join(dpath, key + ".webp")
              with open(image_out_path, "w") as fp:
                  fp.write(val)
              count += 1
              if (
                  png_conv
              ):  # in case WEBP is not supported, extra step of conversion to PNG
                  image_out_path_ = image_out_path
                  image_out_path = os.path.join(dpath, key + ".png")
                  im = Image.open(image_out_path_).convert("RGB")
                  im.save(image_out_path, "png")
                  os.remove(image_out_path_)
              records.append(
                  (
                      os.path.relpath(image_out_path, lsun_dir),
                      lbl_map[category],
                  )
              )
          np.savetxt(manifest_file, records, fmt="%s\t%s")
      print("LSUN {0} {1} dataset ingested.".format(category, dset))
      print("Manifest file is: " + manifest_file)
      return manifest_file
  
file_path: neon/examples/gan/lsun_data.py
imports: import numpy
  import os
  import shutil
  import subprocess
  import json
  import zipfile
  import logging
  from tqdm import tqdm
  from PIL import Image
  from neon.data.aeon_shim import AeonDataLoader
  from neon.data.dataloader_transformers import OneHot, TypeCast, ValueNormalize
  from neon.util.persist import get_data_cache_or_nothing
  from future import standard_library
  from future.moves.urllib.request import urlopen
label_desc: Use image node_id 3 for calling a global function with example usage: ingest_lsun(lsun_dir, category, dset, lbl_map, overwrite, png_conv) and returns: manifest_file, manifest_file