code: def display(tfrecord_dir):
      print('Loading dataset "%s"' % tfrecord_dir)
      tflib.init_tf({"gpu_options.allow_growth": True})
      dset = dataset.TFRecordDataset(
          tfrecord_dir,
          max_label_size="full",
          repeat=False,
          shuffle_mb=0,
      )
      tflib.init_uninitialized_vars()
      import cv2  # pip install opencv-python
  
      idx = 0
      while True:
          try:
              images, labels = dset.get_minibatch_np(1)
          except tf.errors.OutOfRangeError:
              break
          if idx == 0:
              print("Displaying images")
              cv2.namedWindow("dataset_tool")
              print("Press SPACE or ENTER to advance, ESC to exit")
          print("\nidx = %-8d\nlabel = %s" % (idx, labels[0].tolist()))
          cv2.imshow(
              "dataset_tool", images[0].transpose(1, 2, 0)[:, :, ::-1]
          )  # CHW => HWC, RGB => BGR
          idx += 1
          if cv2.waitKey() == 27:
              break
      print("\nDisplayed %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 2 for calling a global function with example usage: display(tfrecord_dir) without return types