code: def add_image(self, img):
      if (
          self.print_progress
          and self.cur_images % self.progress_interval == 0
      ):
          print(
              "%d / %d\r" % (self.cur_images, self.expected_images),
              end="",
              flush=True,
          )
      if self.shape is None:
          self.shape = img.shape
          self.resolution_log2 = int(np.log2(self.shape[1]))
          assert self.shape[0] in [1, 3]
          assert self.shape[1] == self.shape[2]
          assert self.shape[1] == 2**self.resolution_log2
          tfr_opt = tf.python_io.TFRecordOptions(
              tf.python_io.TFRecordCompressionType.NONE
          )
          for lod in range(self.resolution_log2 - 1):
              tfr_file = self.tfr_prefix + "-r%02d.tfrecords" % (
                  self.resolution_log2 - lod
              )
              self.tfr_writers.append(
                  tf.python_io.TFRecordWriter(tfr_file, tfr_opt)
              )
      assert img.shape == self.shape
      for lod, tfr_writer in enumerate(self.tfr_writers):
          if lod:
              img = img.astype(np.float32)
              img = (
                  img[:, 0::2, 0::2]
                  + img[:, 0::2, 1::2]
                  + img[:, 1::2, 0::2]
                  + img[:, 1::2, 1::2]
              ) * 0.25
          quant = np.rint(img).clip(0, 255).astype(np.uint8)
          ex = tf.train.Example(
              features=tf.train.Features(
                  feature={
                      "shape": tf.train.Feature(
                          int64_list=tf.train.Int64List(
                              value=quant.shape
                          )
                      ),
                      "data": tf.train.Feature(
                          bytes_list=tf.train.BytesList(
                              value=[quant.tostring()]
                          )
                      ),
                  }
              )
          )
          tfr_writer.write(ex.SerializeToString())
      self.cur_images += 1
  
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 4 for calling the TFRecordExporter obj's underlying member method code with example usage: obj.add_image(img) without return types