code: def run_for_dataset(args, dataset):
      print("Build pipeline")
      pipes = [
          DetectionPipeline(args, device_id, dataset[0], dataset[1])
          for device_id in range(args.num_gpus)
      ]
      [pipe.build() for pipe in pipes]
  
      set_iters(args, pipes[0].epoch_size("Reader"))
  
      for iter in range(args.iters):
          for pipe in pipes:
              (
                  labels,
                  image_ssd_crop,
                  image_decode_crop,
                  image_slice_cpu,
                  image_slice_gpu,
                  boxes_ssd_crop,
                  boxes_random_crop,
                  labels_ssd_crop,
                  labels_random_crop,
                  image_resized_cpu,
                  image_resized_gpu,
                  image_normalized_cpu,
                  image_normalized_gpu,
                  image_twisted_cpu,
                  image_twisted_gpu,
                  image_legacy_twisted_cpu,
                  image_legacy_twisted_gpu,
                  image_flipped_cpu,
                  image_flipped_gpu,
                  boxes_flipped_cpu,
                  boxes_flipped_gpu,
                  encoded_boxes_cpu,
                  encoded_boxes_gpu,
                  encoded_labels_cpu,
                  encoded_labels_gpu,
                  encoded_offset_boxes_cpu,
                  encoded_offset_boxes_gpu,
                  encoded_offset_labels_cpu,
                  encoded_offset_labels_gpu,
                  image_decode_crop_gpu,
                  image_gpu_slice_gpu,
              ) = [np.squeeze(to_array(out)) for out in pipe.run()]
              # Check reader
              labels = ((labels > 0) & (labels <= 80)).all()
  
              # Check cropping ops
              decode_crop = compare(image_ssd_crop, image_decode_crop)
              slice_cpu = compare(image_ssd_crop, image_slice_cpu)
              slice_gpu = compare(image_ssd_crop, image_slice_gpu)
              decode_crop_gpu = compare(
                  image_gpu_slice_gpu, image_decode_crop_gpu
              )
              image_crop = (
                  decode_crop
                  and slice_cpu
                  and slice_gpu
                  and decode_crop_gpu
              )
              boxes_crop = compare(boxes_ssd_crop, boxes_random_crop)
              labels_crop = compare(labels_ssd_crop, labels_random_crop)
              crop = image_crop and boxes_crop and labels_crop
  
              hsv_bc_twist = relaxed_compare(
                  image_twisted_gpu, image_legacy_twisted_gpu, eps=4
              )
  
              # Check resizing ops
              resize = relaxed_compare(
                  val_1=image_resized_cpu,
                  val_2=image_resized_gpu,
                  reference=resize_ref(image_ssd_crop, (300, 300)),
                  border=1,
              )
  
              # Check normalizing ops
              image_normalized_ref = normalize_ref(image_resized_cpu)
              normalize = compare(
                  image_normalized_cpu,
                  image_normalized_gpu,
                  image_normalized_ref,
              )
  
              # Check twisting ops
              twist_gpu_cpu = relaxed_compare(
                  image_twisted_cpu, image_twisted_gpu, eps=2
              )
              twist = twist_gpu_cpu and hsv_bc_twist
  
              # Check flipping ops
              (
                  image_flipped_ref,
                  boxes_flipped_ref,
              ) = horizontal_flip_ref(image_resized_cpu, boxes_ssd_crop)
              image_flip = compare(
                  image_flipped_cpu,
                  image_flipped_gpu,
                  image_flipped_ref,
              )
              boxes_flip = compare(
                  boxes_flipped_cpu,
                  boxes_flipped_gpu,
                  boxes_flipped_ref,
              )
              flip = image_flip and boxes_flip
  
              # Check box encoding ops
              encoded_boxes = compare(
                  encoded_boxes_cpu, encoded_boxes_gpu
              )
              encoded_labels = compare(
                  encoded_labels_cpu, encoded_labels_gpu
              )
              encoded_boxes_offset = compare(
                  encoded_offset_boxes_cpu, encoded_offset_boxes_gpu
              )
              encoded_labels_offset = compare(
                  encoded_offset_labels_cpu, encoded_offset_labels_gpu
              )
              encoded_labels_cpu = compare(
                  encoded_labels_cpu, encoded_offset_labels_cpu
              )
              encoded_labels_gpu = compare(
                  encoded_labels_gpu, encoded_offset_labels_gpu
              )
              box_encoder = (
                  encoded_boxes
                  and encoded_boxes_offset
                  and encoded_labels
                  and encoded_labels_offset
                  and encoded_labels_cpu
                  and encoded_labels_gpu
              )
  
              if (
                  not labels
                  or not crop
                  or not resize
                  or not normalize
                  or not twist
                  or not flip
                  or not box_encoder
              ):
                  print("Error during iteration", iter)
                  print("Labels = ", labels)
  
                  print("Crop = ", crop)
                  print("  decode_crop =", decode_crop)
                  print("  decode_crop_gpu =", decode_crop_gpu)
                  print("  slice_cpu =", slice_cpu)
                  print("  slice_gpu =", slice_gpu)
                  print("  boxes_crop =", boxes_crop)
                  print("  labels_crop =", labels_crop)
  
                  print("Resize =", resize)
  
                  print("Normalize =", normalize)
  
                  print("Twist =", twist)
                  print("  twist gpu vs cpu = ", twist_gpu_cpu)
                  print("  HSV + BC vs legacy Twist = ", hsv_bc_twist)
  
                  print("Flip =", flip)
                  print("  image_flip =", image_flip)
                  print("  boxes_flip =", boxes_flip)
  
                  print("Box encoder =", box_encoder)
                  print("  encoded_boxes =", encoded_boxes)
                  print(
                      "  encoded_boxes_offset =", encoded_boxes_offset
                  )
                  print("  encoded_labels =", encoded_labels)
                  print(
                      "  encoded_labels_offset =", encoded_labels_offset
                  )
                  print("  encoded_labels_cpu =", encoded_labels_cpu)
                  print("  encoded_labels_gpu =", encoded_labels_gpu)
  
                  exit(1)
  
          if not iter % 100:
              print("Iteration: {}/ {}".format(iter + 1, args.iters))
      print("OK")
  
imports: import argparse
  import os
  from math import ceil, sqrt
  import numpy
  import nvidia.dali.ops
  import nvidia.dali.types
  from nvidia.dali.pipeline import Pipeline
  from test_utils import get_dali_extra_path
  from test_utils import to_array
label_desc: Use image node_id 11 for calling a global function with example usage: run_for_dataset(args, dataset) without return types