code: def _test_iter_setup(use_fn_api, by_name, device):
      batch_size = 7
  
      class IterSetupPipeline(Pipeline):
          def __init__(self, iterator, num_threads, device_id, device):
              super(IterSetupPipeline, self).__init__(
                  batch_size=iterator.batch_size,
                  num_threads=num_threads,
                  device_id=device_id,
              )
  
              self.iterator = iterator
              self._device = device
  
          def define_graph(self):
              if use_fn_api:
                  self.batch_1 = fn.external_source(
                      device=self._device, name="src1"
                  )
                  self.batch_2 = fn.external_source(
                      device=self._device, name="src2"
                  )
              else:
                  input_1 = ops.ExternalSource(device=self._device)
                  input_2 = ops.ExternalSource(device=self._device)
                  self.batch_1 = input_1(name="src1")
                  self.batch_2 = input_2(name="src2")
              return [self.batch_1, self.batch_2]
  
          def iter_setup(self):
              batch_1, batch_2 = next(self.iterator)
              if by_name:
                  self.feed_input("src1", batch_1)
                  self.feed_input("src2", batch_2)
              else:
                  self.feed_input(self.batch_1, batch_1)
                  self.feed_input(self.batch_2, batch_2)
  
      iter_num = 5
      source = TestIterator(iter_num, batch_size, [2, 3])
      pipe = IterSetupPipeline(iter(source), 3, 0, device)
      pipe.build()
  
      run_and_check(pipe, source)
  
imports: import functools
  import numpy
  import nvidia.dali.fn
  import nvidia.dali.ops
  from nvidia.dali import Pipeline
  from nose_utils import assert_raises
  from test_utils import check_output
label_desc: Use image node_id 7 for calling a global function with example usage: _test_iter_setup(use_fn_api, by_name, device) and returns: list