code: def gather_ids(
      pipes,
      epochs_run=0,
      batch_size=1,
      num_gpus_arg=None,
      gpus_arg=None,
  ):
      dataset_size = pipes[0].epoch_size("Reader")
      num_gpus = len(pipes)
      if num_gpus_arg:
          num_gpus = num_gpus_arg
      iterate_over = range(num_gpus)
      if gpus_arg:
          iterate_over = gpus_arg
      img_ids_list = [[] for _ in pipes]
  
      # Each GPU needs to iterate from `shard_id * data_size / num_gpus` samples
      # to `(shard_id + 1)* data_size / num_gpus`.
      # After each epoch, each GPU moves to the next shard.
      # The `epochs_run` variable  takes into account that after epoch readers advance to the
      # next shard. If shuffle_after_epoch or stick_to_shard is set, it doesn't matter
      # and could/should be 0; it is relevant only if pad_last_batch is False, otherwise each
      # shard has the same size due to padding.
      for img_ids_l, pipe, n in zip(img_ids_list, pipes, iterate_over):
          shard_size = (
              dataset_size * (n + 1 + epochs_run) // num_gpus
              - dataset_size * (n + epochs_run) // num_gpus
          )
          iters = int(math.ceil(shard_size / batch_size))
          for _ in range(iters):
              val = np.concatenate(pipe.run()[0].as_array())
              img_ids_l.append(val)
  
      set_list = []
      for elm in img_ids_list:
          set_list.append(set(np.concatenate(elm)))
      if len(pipes) == 1:
          return img_ids_list[0], set_list[0], epochs_run + 1
      else:
          return img_ids_list, set_list, epochs_run + 1
  
imports: import nose_utils
  import math
  from nvidia.dali.pipeline import Pipeline
  import nvidia.dali.ops
  import numpy
  import os
  from test_utils import get_dali_extra_path
label_desc: Use image node_id 3 for calling a global function with example usage: gather_ids(pipes, epochs_run, batch_size, num_gpus_arg, gpus_arg) and returns: img_ids_list,  set_list,  unknown, img_ids_list,  set_list,  unknown