code: def _test_scalar(device, as_tensors):
      """Test propagation of scalars from external source"""
      batch_size = 4
      src_pipe = Pipeline(batch_size, 1, 0)
      src_ext = fn.external_source(
          source=lambda i: [
              np.float32(i * 10 + i + 1) for i in range(batch_size)
          ],
          device=device,
      )
      src_pipe.set_outputs(src_ext)
  
      src_pipe.build()
      dst_pipe = Pipeline(
          batch_size, 1, 0, exec_async=False, exec_pipelined=False
      )
      dst_pipe.set_outputs(
          fn.external_source(name="ext", device=device)
      )
      dst_pipe.build()
  
      for iter in range(3):
          src = src_pipe.run()
          data = src[0]
          if as_tensors:
              data = [data[i] for i in range(len(data))]
          dst_pipe.feed_input("ext", data)
          dst = dst_pipe.run()
          check_batch(src[0], dst[0], batch_size, 0, 0, "")
  
imports: import random
  import nvidia.dali.fn
  import nvidia.dali.ops
  import nvidia.dali.types
  import numpy
  from nvidia.dali import Pipeline, pipeline_def
  from test_utils import check_batch
  from nose_utils import raises, assert_warns, assert_raises
  from nvidia.dali.types import DALIDataType
  from numpy.random import default_rng
label_desc: Use image node_id 6 for calling a global function with example usage: _test_scalar(device, as_tensors) without return types