code: def extract(tfrecord_dir, output_dir):
      print('Loading dataset "%s"' % tfrecord_dir)
      tflib.init_tf({"gpu_options.allow_growth": True})
      dset = dataset.TFRecordDataset(
          tfrecord_dir, max_label_size=0, repeat=False, shuffle_mb=0
      )
      tflib.init_uninitialized_vars()
  
      print('Extracting images to "%s"' % output_dir)
      if not os.path.isdir(output_dir):
          os.makedirs(output_dir)
      idx = 0
      while True:
          if idx % 10 == 0:
              print("%d\r" % idx, end="", flush=True)
          try:
              images, _labels = dset.get_minibatch_np(1)
          except tf.errors.OutOfRangeError:
              break
          if images.shape[1] == 1:
              img = PIL.Image.fromarray(images[0][0], "L")
          else:
              img = PIL.Image.fromarray(
                  images[0].transpose(1, 2, 0), "RGB"
              )
          img.save(os.path.join(output_dir, "img%08d.png" % idx))
          idx += 1
      print("Extracted %d images." % idx)
  
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 3 for calling a global function with example usage: extract(tfrecord_dir, output_dir) without return types