code: def test_select(dev):
      def _collect_batch(p):
          p.build()
          batches = p.run()
          if dev == "gpu":
              batches = (batch.as_cpu() for batch in batches)
          return tuple(
              [np.array(sample) for sample in batch]
              for batch in batches
          )
  
      ops = [overexpose, blend_edges, cutout]
      num_magnitude_bins = 4
      batch_size = num_magnitude_bins * len(ops)
  
      @pipeline_def(
          enable_conditionals=True,
          batch_size=batch_size,
          num_threads=4,
          device_id=0,
      )
      def pipeline_select():
          op_idx = sample_info(
              lambda info: info.idx_in_batch % len(ops)
          )
          magnitude_bin = sample_info(
              lambda info: info.idx_in_batch % num_magnitude_bins
          )
          image, _ = fn.readers.file(
              name="Reader", file_root=images_dir
          )
          image = fn.decoders.image(
              image, device="cpu" if dev == "cpu" else "mixed"
          )
          return select(
              ops,
              op_idx,
              image,
              magnitude_bin=magnitude_bin,
              num_magnitude_bins=4,
          )
  
      @pipeline_def(batch_size=batch_size, num_threads=4, device_id=0)
      def pipeline_refs():
          magnitude_bin = sample_info(
              lambda info: info.idx_in_batch % num_magnitude_bins
          )
          image, _ = fn.readers.file(
              name="Reader", file_root=images_dir
          )
          image = fn.decoders.image(
              image, device="cpu" if dev == "cpu" else "mixed"
          )
          return tuple(
              op(
                  image,
                  magnitude_bin=magnitude_bin,
                  num_magnitude_bins=4,
              )
              for op in ops
          )
  
      (batch_select,) = _collect_batch(pipeline_select())
      ref_batches = _collect_batch(pipeline_refs())
      ref_batch = [
          ref_batches[idx % len(ops)][idx] for idx in range(batch_size)
      ]
      check_batch(batch_select, ref_batch, max_allowed_error=1e-6)
  
file_path: DALI/dali/test/python/auto_aug/test_select.py
imports: import os
  import numpy
  from nose2.tools import params
  from nvidia.dali import fn, pipeline_def, types
  from nvidia.dali.auto_aug.core import augmentation, select
  from test_utils import get_dali_extra_path, check_batch
label_desc: Use image node_id 6 for calling a global function with example usage: test_select(dev) and returns: tuple, select, tuple