code: def test_fw_iter(IteratorClass, args):
      iterator_name = (
          IteratorClass.__module__ + "." + IteratorClass.__name__
      )
      print("Start testing {}".format(iterator_name))
      sess = None
      daliop = None
      dali_train_iter = None
      images = []
      labels = []
  
      pipes = [
          RN50Pipeline(
              batch_size=args.batch_size,
              num_threads=args.workers,
              device_id=n,
              num_gpus=args.gpus,
              data_paths=data_paths,
              prefetch=PREFETCH,
              fp16=args.fp16,
              nhwc=args.nhwc,
          )
          for n in range(args.gpus)
      ]
      [pipe.build() for pipe in pipes]
      iters = args.iters
      if args.iters < 0:
          iters = pipes[0].epoch_size("Reader")
          assert all(
              pipe.epoch_size("Reader") == iters for pipe in pipes
          )
          iters_tmp = iters
          iters = iters // args.batch_size
          if iters_tmp != iters * args.batch_size:
              iters += 1
          iters_tmp = iters
  
          iters = iters // args.gpus
          if iters_tmp != iters * args.gpus:
              iters += 1
  
      if iterator_name == "nvidia.dali.plugin.tf.DALIIterator":
          daliop = IteratorClass()
          for dev in range(args.gpus):
              with tf.device("/gpu:%i" % dev):
                  if args.fp16:
                      out_type = tf.float16
                  else:
                      out_type = tf.float32
                  image, label = daliop(
                      pipeline=pipes[dev],
                      shapes=[(args.batch_size, 3, 224, 224), ()],
                      dtypes=[out_type, tf.int32],
                  )
                  images.append(image)
                  labels.append(label)
          gpu_options = GPUOptions(per_process_gpu_memory_fraction=0.5)
          config = ConfigProto(gpu_options=gpu_options)
          sess = Session(config=config)
  
      end = time.time()
      for i in range(args.epochs):
          if i == 0:
              print("Warm up")
          else:
              print("Test run " + str(i))
          data_time = AverageMeter()
  
          if iterator_name == "nvidia.dali.plugin.tf.DALIIterator":
              assert sess is not None
              for j in range(iters):
                  sess.run([images, labels])
                  data_time.update(time.time() - end)
                  if j % args.print_freq == 0:
                      speed = (
                          args.gpus * args.batch_size / data_time.avg
                      )
                      print(
                          f"{iterator_name} {j + 1}/ {iters}, avg time: {data_time.avg} [s], "
                          f"worst time: {data_time.max_val} [s], speed: {speed} [img/s]"
                      )
                  end = time.time()
          else:
              dali_train_iter = IteratorClass(
                  pipes, reader_name="Reader"
              )
              j = 0
              for it in iter(dali_train_iter):
                  data_time.update(time.time() - end)
                  if j % args.print_freq == 0:
                      speed = (
                          args.gpus * args.batch_size / data_time.avg
                      )
                      print(
                          f"{iterator_name} {j + 1}/ {iters}, avg time: {data_time.avg} [s], "
                          f"worst time: {data_time.max_val} [s], speed: {speed} [img/s]"
                      )
                  end = time.time()
                  j = j + 1
                  if j > iters:
                      break
  
file_path: DALI/dali/test/python/test_RN50_data_fw_iterators.py
imports: from nvidia.dali.pipeline import Pipeline
  import nvidia.dali.ops
  import nvidia.dali.types
  import argparse
  import time
label_desc: Use image node_id 1 for calling a global function with example usage: test_fw_iter(IteratorClass, args) without return types