code: def create_mnist(tfrecord_dir, mnist_dir):
      print('Loading MNIST from "%s"' % mnist_dir)
      import gzip
  
      with gzip.open(
          os.path.join(mnist_dir, "train-images-idx3-ubyte.gz"), "rb"
      ) as file:
          images = np.frombuffer(file.read(), np.uint8, offset=16)
      with gzip.open(
          os.path.join(mnist_dir, "train-labels-idx1-ubyte.gz"), "rb"
      ) as file:
          labels = np.frombuffer(file.read(), np.uint8, offset=8)
      images = images.reshape(-1, 1, 28, 28)
      images = np.pad(
          images,
          [(0, 0), (0, 0), (2, 2), (2, 2)],
          "constant",
          constant_values=0,
      )
      assert (
          images.shape == (60000, 1, 32, 32)
          and images.dtype == np.uint8
      )
      assert labels.shape == (60000,) and labels.dtype == np.uint8
      assert np.min(images) == 0 and np.max(images) == 255
      assert np.min(labels) == 0 and np.max(labels) == 9
      onehot = np.zeros(
          (labels.size, np.max(labels) + 1), dtype=np.float32
      )
      onehot[np.arange(labels.size), labels] = 1.0
  
      with TFRecordExporter(tfrecord_dir, images.shape[0]) as tfr:
          order = tfr.choose_shuffled_order()
          for idx in range(order.size):
              tfr.add_image(images[order[idx]])
          tfr.add_labels(onehot[order])
  
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 5 for calling a global function with example usage: create_mnist(tfrecord_dir, mnist_dir) without return types